Difference between revisions of "MessageDialog"
From Xojo Documentation
(→Notes) |
(→Notes) |
||
Line 66: | Line 66: | ||
A '''MessageDialog''' dialog can have up to three buttons, an icon, and main and subordinate text. On Windows and Linux, it can also have text in its title bar. By default, only the ActionButton's Visible property is [[True]]. To use any other buttons, you must set their Visible properties to [[True]]. | A '''MessageDialog''' dialog can have up to three buttons, an icon, and main and subordinate text. On Windows and Linux, it can also have text in its title bar. By default, only the ActionButton's Visible property is [[True]]. To use any other buttons, you must set their Visible properties to [[True]]. | ||
− | {{Warning| You should avoid using | + | {{Warning| You should avoid using MessageDialog for displaying debugging messages. The displaying of the dialog will alter event order and may give unexpected results. Instead use the [[UserGuide:Debugger_Usage|Debugger]], [[System.DebugLog]] or your own logging mechanism.}} |
===Icons=== | ===Icons=== |
Revision as of 17:03, 25 October 2019
![]() |
Supported Platforms Project Types: Desktop Platforms: macOS, Windows, Linux |
Used to design and display customized message dialog boxes.
Properties | |||||||
|
Methods | ||
|
Shared Methods | |
|
Class Constants
The following class constants are used to specify the value of the Icon property.
Class Constant | Description |
---|---|
GraphicNone | No icon |
GraphicNote | The OS's Note icon or the application icon on macOS |
GraphicCaution | The OS's Caution icon. On macOS, the application icon superimposed on the Caution icon. |
GraphicStop | The OS's Stop icon. On macOS, the application icon. |
GraphicQuestion | The OS's Question icon. On macOS, the application icon. |
Notes
A MessageDialog dialog can have up to three buttons, an icon, and main and subordinate text. On Windows and Linux, it can also have text in its title bar. By default, only the ActionButton's Visible property is True. To use any other buttons, you must set their Visible properties to True.
You should avoid using MessageDialog for displaying debugging messages. The displaying of the dialog will alter event order and may give unexpected results. Instead use the Debugger, System.DebugLog or your own logging mechanism. |
Icons
The four icons supported by MessageDialog are not the same on all platforms. In particular, macOS shows the generic application icon for the values of 0, 2, and 3.
The following series of screenshot shows the icons on the three platforms.
Note | Caution | Stop | Question | |
---|---|---|---|---|
Windows | ||||
macOS | ||||
Linux |
Handling the button click
After the user has clicked a button in the MessageDialog, the ShowModal method returns the MessageDialogButton that was pressed. You need to check this against the three types of MessageDialogButtons belonging to the MessageDialog to determine which button the user clicked. See the example.
Example
The following example creates and manages a “Save Changes” dialog box without the need to create an instance of the Window class.
Var b As MessageDialogButton // for handling the result
d.Icon = MessageDialog.GraphicCaution // display warning icon
d.ActionButton.Caption = "Save"
d.CancelButton.Visible = True // show the Cancel button
d.AlternateActionButton.Visible = True // show the "Don't Save" button
d.AlternateActionButton.Caption = "Don't Save"
d.Message = "Do you want to save changes to this document before closing?"
d.Explanation = "If you don't save, your changes will be lost. "
b = d.ShowModal // display the dialog
Select Case b // determine which button was pressed.
Case d.ActionButton
// user pressed Save
Case d.AlternateActionButton
// user pressed Don't Save
Case d.CancelButton
// user pressed Cancel
End Select
See Also
MessageDialogButton, Window classes.