Skip to main content

MessageDialog

Detailed Description

The MessageDialog class is a modal dialog for informing the user or for asking the user a question and receiving an answer. A message dialog can also display an icon and standard buttons for accepting a user response.
A message dialog supports four predefined message levels, or message types, which really only differ in the predefined icon they each show. Specify one of the four predefined message types by setting the icon property to one of the predefined icons. The following rules are guidelines:

IconNameDescription
QuestionFor asking a question during normal operations.
InformationFor reporting information about normal operations.
WarningFor reporting non-critical errors.
CriticalFor reporting critical errors.

A message dialog supports four standard buttons, these enums describe flags for standard buttons:

ConstantValueDescription
Ok0x0001An "OK" button.
Cancel0x0002A "Cancel" button.
Yes0x0004A "Yes" button.
No0x0008A "No" button.

Example code

Static functions are available for creating, they are information(), question(), warning() and critical().

MessageDialog.information('Information', 'The file has been loaded.', MessageDialog.Ok);

You can get the button which is clicked inside the callback function.

const buttons = MessageDialog.Yes | MessageDialog.No;
const buttonCallback = (button: number): void => {
switch (button) {
case MessageDialog.Yes:
// "Yes" Button was clicked
break;
case MessageDialog.No:
// "No" Button was clicked
break;
default:
// should never be reached
break;
};
};
MessageDialog.question('Question', 'Do you want to save your changes?', buttons, buttonCallback);