closeDialog: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
(10 intermediate revisions by 6 users not shown) | |||
Line 2: | Line 2: | ||
|name=closeDialog | |name=closeDialog | ||
|version=1.3b49 | |version=1.3b49 | ||
|description=Closes the specified macro dialog that | |description=Closes the specified macro dialog that was previously created using {{roll | dialog}}. If the | ||
[[dialog]] is not open then the function has no effect. | [[dialog]] is not open then the function has no effect. | ||
The most common use for this function is closing a [[dialog]] based from a macro that is run when clicking on a link or button for the | The most common use for this function is closing a [[dialog]] based from a macro that is run when clicking on a link or button for the | ||
[[dialog]] that has no close button. | [[dialog]] that has no close button. | ||
'''NOTE''' In later versions of maptool (tested in b74) this works only for dialogs opened with {{roll|dialog}}. Dialogs created using option '''temporary=0''' will not be removed and only made not visible. Frames cant be closed with this. But there is a new analog function available for that, too. See {{func|closeFrame}} | |||
|usage= | |usage= | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
[h: closeDialog(name)] | [h: closeDialog(name)] | ||
</ | </syntaxhighlight> | ||
|example= | |example= | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
[h: closeDialog("CharacterSheet")] | [h: closeDialog("CharacterSheet")] | ||
</ | </syntaxhighlight> | ||
Assuming a [[dialog]] called "Name Entry" has been created without the input flag but containing a form. In the macro called when the | Assuming a [[dialog]] called "Name Entry" has been created without the input flag but containing a form. In the macro called when the | ||
form is submitted you can use the following logic to check that the "name" field is not blank and close the [[dialog]]. | form is submitted you can use the following logic to check that the "name" field is not blank and close the [[dialog]]. | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
[h, if(listGet(macro.args, "name")), code: { | [h, if(listGet(macro.args, "name")), code: { | ||
[closeDialog("Name Entry")] | [closeDialog("Name Entry")] | ||
Line 25: | Line 29: | ||
<!-- otherwise we would do something here to tell the user to provide a name --> | <!-- otherwise we would do something here to tell the user to provide a name --> | ||
}] | }] | ||
</ | </syntaxhighlight> | ||
}} | }} | ||
[[Category:Dialog Function]] | [[Category:Dialog Function]] |
Latest revision as of 23:59, 16 November 2024
closeDialog() Function
• Introduced in version 1.3b49
Closes the specified macro dialog that was previously created using [ dialog():]. If the
dialog is not open then the function has no effect.
The most common use for this function is closing a dialog based from a macro that is run when clicking on a link or button for the dialog that has no close button.
NOTE In later versions of maptool (tested in b74) this works only for dialogs opened with [dialog():]. Dialogs created using option temporary=0 will not be removed and only made not visible. Frames cant be closed with this. But there is a new analog function available for that, too. See closeFrame()Usage
[h: closeDialog(name)]
Example
[h: closeDialog("CharacterSheet")]
Assuming a dialog called "Name Entry" has been created without the input flag but containing a form. In the macro called when the form is submitted you can use the following logic to check that the "name" field is not blank and close the dialog.
[h, if(listGet(macro.args, "name")), code: {
[closeDialog("Name Entry")]
} ; {
<!-- otherwise we would do something here to tell the user to provide a name -->
}]