Difference between revisions of "MessageDialog.ShowModalWithin"

From Xojo Documentation

(SMBot: new page by automated transformation)
 
 
(10 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 +
{{DeprecatedItem|version=2021r3|replacement=[[MessageDialog.ShowModal]]}}
 
{{MethodBox
 
{{MethodBox
 
| name=ShowModalWithin
 
| name=ShowModalWithin
Line 4: Line 5:
 
| ownertype=class
 
| ownertype=class
 
| scope=public
 
| scope=public
| parameters=Parent as [[WindowClass|Window]]
+
| parameters=Parent as [[Window]]
 
| returntype=[[MessageDialogButton]]
 
| returntype=[[MessageDialogButton]]
 
| platform=all
 
| platform=all
 
| newinversion=2005r1
 
| newinversion=2005r1
 
}}
 
}}
Displays the '''MessageDialog''' window as a sheet window (Mac OS X only) for the passed [[WindowClass|Window]].  
+
{{Description
 +
|text = Displays the '''MessageDialog''' window as a sheet window (macOS only) for the passed [[Window]]. }}
  
On other platforms, it displays the MessageDialog as a modal dialog (same as ShowModal). Returns a [[MessageDialogButton]], which indicates which button was pressed. To find out which button was pressed, compare it to the button instances in the dialog.
+
==Notes==
 +
On non-Mac platforms, it displays the MessageDialog as a modal dialog (same as ShowModal). Returns a [[MessageDialogButton]], which indicates which button was pressed. To find out which button was pressed, compare it to the button instances in the dialog.
 +
 
 +
== Sample Code ==
 +
The following example creates and manages a "Save Changes" dialog box without the need to create an instance of the [[Window]] class.
 +
 
 +
<rbcode>
 +
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.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 Window1
 +
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
 +
</rbcode>

Latest revision as of 13:53, 21 September 2021

Method

MessageDialog.ShowModalWithin(Parent as Window) As MessageDialogButton

New in 2005r1

Supported for all project types and targets.

Displays the MessageDialog window as a sheet window (macOS only) for the passed Window.

Notes

On non-Mac platforms, it displays the MessageDialog as a modal dialog (same as ShowModal). Returns a MessageDialogButton, which indicates which button was pressed. To find out which button was pressed, compare it to the button instances in the dialog.

Sample Code

The following example creates and manages a "Save Changes" dialog box without the need to create an instance of the Window class.

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.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 Window1
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