Error getting tags :
error 404Error getting tags :
error 404 modal | revDocs | RunRev
Welcome Guest (Log in)
Product Edition
Version
modal
Basics
Expander triangle
Type
Command
Syntax

modal stack

Introduced
1.0
Environment
Desktop,Server
Platform Support
MacOS,Mac OS X,Windows,Linux
Security
None required
Summary
Opens a stack as a modal dialog box.
Examples

modal stack "Custom Answer Dialog"
modal stack x of stacksToPresent

Additional Comments
Expander triangle

Use the modal command to display a stack as a custom modal dialog box.

Parameters:

The stack is any stack reference.

Comments:

The modal command opens the stack centered over the defaultStack, regardless of the stack's rectangle and location properties.

While a modal dialog box is open, other windows cannot be edited or brought to the front. Because of this, you should use modal dialog boxes only when a stack must obtain feedback from the user before it can continue. This can be problematic if no means of dismissing the stack is provided. To remedy this situation select "stack mode" -> "Toplevel" from the stack's context menu. The context menu can be accessed by using, Shift-Control-Right--Click on Windows or Shift-Command-Right-Click/Command-Control-Shift-Click on Mac.

If the stack is already open, the modal command closes the stack and reopens it as a modal dialog box, so closeStack and openStack, closeCard and openCard, and (if applicable) closeBackground and openBackground messages are sent to the current card as a result of executing this command. Use the lock messages command before executing modal if you want to prevent the close messages from being sent; the open messages are sent regardless of the setting of the lockMessages property.

If the stack is already displayed as a modal dialog box, the modal command does not close and reopen it.

The modal command pauses the running handler until the modal dialog box is dismissed (usually by clicking a button in the modal dialog box). To return information to the handler about which button was clicked, in the button's script, set a global variable or custom property. After the dialog box is dismissed, the handler can query this variable or property and act accordingly.

Modal dialog boxes cannot be resized or edited. To edit a modal dialog box, use the topLevel command to display it in an editable window. The Browse tool is used in modal dialog boxes, regardless of the current setting of the tool property.

User Comments
Expander triangle
User thumbnail
Oliver Kenyon
StarStarStarStarStar
Oct 12, 2009
Beware of the message path when using the modal command to open a dialog which is a substack of your main application. Doing so will cause messages such as preOpenStack, openStack, preOpenCard and openCard to be sent to the dialog, and if these are not handled, they will be sent to the main application, causing it to execute code. For example:


# Main stack
on preOpenStack
put empty
modal stack "Dialog" -- Dialog is a substack of this stack
put "You should not see this until after the dialog has disappeared"
end preOpenStack


In this case, if the stack "Dialog" does not handle the preOpenStack event, then preOpenStack will be passed to the mainstack again. In this situation, the modal command will simply do nothing as the dialog is already modal. This will lead to the text outputting to the message box when not expected.