MessageDialogButton.Default

From Xojo Documentation

Revision as of 16:34, 24 July 2019 by Gperlman (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Property (As Boolean )
aMessageDialogButton.Default = newBooleanValue
or
BooleanValue = aMessageDialogButton.Default

Supported for all project types and targets.

Set to True to highlight the button as the default button in the MessageDialog. By default, the ActionButton’s Default property is True.

= Notes

The Default button will respond to the Enter and Return keys. Only one button can be the Default button. Some operating systems do not allow one button to be both the Default and Cancel buttons.

Example

This example sets the "Don't Save" button as the default button.

Var d As New MessageDialog //declare the MessageDialog object
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.AlternateActionButton.Default = True // Make it the default
d.Title = "This is the Title (Windows & Linux)"
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.ShowModalWithin(Window1) //display the dialog in the window
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