TWebMessageDlg
Description
Below is a list of the most important properties methods and events for TWebMessageDlg
. This component allows to display modal dialogs (simulated by disabling all controls on the page as the concept of modal dialogs does not exist in web applications).
Result for the following code:
or with an async approach:var
mr: TModalResult;
begin
mr := await(TModalResult, WebInputMessageDlg1.ShowDialog('Please
give your name', WEBLib.Dialogs.mtConfirmation,[mbOK, mbCancel]));
if mr = mrOK then
ShowMessage(‘You entered:’+ WebInputMessageDialog1.InputValue);
end;
end;
![]() |
![]() |
---|---|
Designtime | Runtime |
Properties for TWebInputMessageDlg
Property | Description |
---|---|
DialogResult: TModalResult | Holds the result of calling the dialog |
DialogText: TStringList | List of text used in dialog and dialog buttons. Allows for language customization of the dialog text |
ElementButtonClassName | Optionally sets the CSS classname for the buttons on the dialog when styling via CSS is used |
ElementClassName | Optionally sets the CSS classname for the label when styling via CSS is used |
ElementContentClassName | Optionally sets the CSS classname for the message content area when styling via CSS is used |
ElementDialoghClassName | Optionally sets the CSS classname for the entire dialog area when styling via CSS is used |
ElementID | Optionally sets the HTML element ID for a HTML element in the form HTML file the label needs to be connected with. When connected, no new label is created but the Delphi class is connected with the existing HTML element in the form HTML file |
ElementTitleClassName | Optionally sets the CSS classname for the dialog title area when styling via CSS is used |
InputType: TInputType | Sets the type of the input editor in the dialog. The InputType can be:itText : regular textitEmail : email itDate : date picker itDateTime : date/time picker itFile : file picker itMonth : month number picker itNumber : numeric input itPassword : password entry itSearch : text entry with search & delete button itTime : time picker itURL : URL entry itWeek : week number picker |
InputValue: string | Sets or gets the value entered in the input message dialog |
Message: string | Sets the message to be displayed in the content area of the dialog |
Opacity: single | Sets the opacity level for the dialog |
Title: string | Sets the title text |
Methods for TWebInputMessageDlg
Property | Description |
---|---|
ShowAsync() | Async function returning a promise. Use with pascal res := await(TModalResult, Dialog.ShowAsync; |
ShowDialog(Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; AProc: TDialogResultProc = nil); | Method to show the message. The last parameter is a method pointer for a method that is optionally called when assigned when the dialog is closed |
ShowDialog(Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons): TJSPromise; | Async version of ShowDialog() |
Events for TWebInputMessageDlg
Property | Description |
---|---|
OnButtonClick | Event triggered when a button on the message dialog is clicked |
OnClose | Event triggered when the input messagebox is closed |
Functions for directly getting input
Two variants exist for directly calling a function instead of using a component.
procedure InputMessageDlg(const Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; var AResult: string; AInputType: TInputType = itText; AResultProc: TDialogResultProc = nil);
function InputMessageDlgAsync(const Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; var AResult: string; AInputType: TInputType = itText): integer;
Example with anonymous method:
begin
InputMessageDlg('Please give your name',mtInformation, [mbOK, mbCancel], procedure(res: TModalResult)
begin
ShowMessage('You entered:'+ WebInputMessageDlg1.InputValue);
end);
end;
Example with promise: