frame5 (roll option): Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
m (Text replacement - "source>" to "syntaxhighlight>")
No edit summary
 
(3 intermediate revisions by 3 users not shown)
Line 6: Line 6:


|usage=
|usage=
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
[frame5(frameName [,"width; height; temporary; title; tabtitle; value"] ): { ... }]
[frame5(frameName [,"width; height; temporary; title; tabtitle; value"] ): { ... }]
</syntaxhighlight>
</syntaxhighlight>
{{Note|Any macro that is called from a frame5/dialog5/overlay (e.g. link or submit) can not update the contents of '''ANY''' frame5/dialog5/overlay.  Opening a new one requires updating its contents, so that is out, too.  This is because you can end up with the two GUI threads waiting on each other.  You should be able to update the contents of a frame5/dialog5/overlay from a deferred macro (see {{func|execLink}}), so do this if you need to update the contents of one.  Source: [https://discord.com/channels/296230822262865920/738930686034968637/1159334206153949254 Discord post].
<p>
To avoid this problem when using HTML include, use the newer URL syntax:  {{code|<link type{{=}}"text/css" href{{=}}"lib://MyLib/macro/myCSS.css">}}. The URL goes through a separate code path in MapTool which handles the threading issues.}}


The first parameter, shown as '''frameName''', should be a double-quoted string that specifies the internal name of the frame window.  The visible title that appears in the title bar of the window is set separately, either by using HTML that appears inside the frame itself or use of the '''title''' parameter from b50 forward.  Any attempts to open another frame with the same name instead cause the old contents to be removed and new contents displayed.  Note this behavior relates to the internal name of the frame, not the displayed title of the frame as multiple frames can share a title.  Once the named frame is opened and resized by the user, that size becomes its default opening size in the future, unless the temporary option is set to "1".
The first parameter, shown as '''frameName''', should be a double-quoted string that specifies the internal name of the frame window.  The visible title that appears in the title bar of the window is set separately, either by using HTML that appears inside the frame itself or use of the '''title''' parameter from b50 forward.  Any attempts to open another frame with the same name instead cause the old contents to be removed and new contents displayed.  Note this behavior relates to the internal name of the frame, not the displayed title of the frame as multiple frames can share a title.  Once the named frame is opened and resized by the user, that size becomes its default opening size in the future, unless the temporary option is set to "1".
Line 15: Line 19:
The second parameter is optional, it is a semicolon separated [[String Property List]], which could include the following options:
The second parameter is optional, it is a semicolon separated [[String Property List]], which could include the following options:


The '''temporary''' option dictates whether Maptool remembers the size of the frame between displays.  Setting this value to 1 causes Maptool to forget the window size. Example "temporary=1"
'''temporary''' Defaults to 0.  This option dictates whether Maptool remembers the size of the frame between displays.  Setting this value to 1 causes Maptool to forget the window size and the frame is removed when closed. Setting this to 0 will not remove the frame and it will remain available even when closed.   Example "temporary=1"


The '''title''' option sets the title of the frame and replaces the need to set the title from within the HTML code.
The '''title''' option sets the title of the frame and replaces the need to set the title from within the HTML code.
Line 30: Line 34:
|examples=
|examples=
Sample header
Sample header
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
[frame5("Frame Test", "width=300; height=200; temporary=1;"): {
[frame5("Frame Test", "width=300; height=200; temporary=1;"): {
</syntaxhighlight>
</syntaxhighlight>
Line 41: Line 45:
</td>
</td>
<td>
<td>
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
[frame5("Frame Test"): {
[frame5("Frame Test"): {
   <html>
   <html>

Latest revision as of 23:59, 16 November 2024

[frame5():] Roll Option

* Introduced in version 1.6.0

Opens a frame window supporting HTML5. Unlike the modal [dialog5():], frames are dockable panels that are usually intended to remain open. Frames can be closed with a button located in the title bar or via the closeFrame() macro function.

Usage

[frame5(frameName [,"width; height; temporary; title; tabtitle; value"] ): { ... }]


Any macro that is called from a frame5/dialog5/overlay (e.g. link or submit) can not update the contents of ANY frame5/dialog5/overlay. Opening a new one requires updating its contents, so that is out, too. This is because you can end up with the two GUI threads waiting on each other. You should be able to update the contents of a frame5/dialog5/overlay from a deferred macro (see execLink()), so do this if you need to update the contents of one. Source: Discord post.

To avoid this problem when using HTML include, use the newer URL syntax: <link type="text/css" href="lib://MyLib/macro/myCSS.css">. The URL goes through a separate code path in MapTool which handles the threading issues.


The first parameter, shown as frameName, should be a double-quoted string that specifies the internal name of the frame window. The visible title that appears in the title bar of the window is set separately, either by using HTML that appears inside the frame itself or use of the title parameter from b50 forward. Any attempts to open another frame with the same name instead cause the old contents to be removed and new contents displayed. Note this behavior relates to the internal name of the frame, not the displayed title of the frame as multiple frames can share a title. Once the named frame is opened and resized by the user, that size becomes its default opening size in the future, unless the temporary option is set to "1".


The second parameter is optional, it is a semicolon separated String Property List, which could include the following options:

temporary Defaults to 0. This option dictates whether Maptool remembers the size of the frame between displays. Setting this value to 1 causes Maptool to forget the window size and the frame is removed when closed. Setting this to 0 will not remove the frame and it will remain available even when closed. Example "temporary=1"

The title option sets the title of the frame and replaces the need to set the title from within the HTML code.

The tabtitle is the title shown when the frame is minimized. If not used as a parameter, the tabtitle is the same as the frame's title.

The width and height options determine the (initial) size of the frame. Depending whether temporary has been set or not the frame will always open with these dimensions.

The scrollreset option, if equals to 1, resets the scrolling to the top of the frame once the frame is loaded with new HTML content.

The last parameter is value. It can be used to store some data inside the frame. For example, if a frame display the equipment of a character, the value parameter can be set to the token id of that character, so that you can know which character's equipment is being displayed.

Examples

Sample header

[frame5("Frame Test", "width=300; height=200; temporary=1;"): {

The following code opens up a frame that contains the HTML as shown here:

[frame5("Frame Test"): {
  <html>
    <head>
      <title>Test of Frame Windows</title>
    </head>
    <body>
    <table border="1">
    <tr><th>Column 1</th><th>Column 2</th><th>Column 3</th></tr>
    <tr><td>Line 1, Col 1</td><td colspan="2">Line 1, Cols 2 and 3</td></tr>
    <tr><td rowspan="2">Lines 2 and 3, Col 1</td><td>Line 2, Col 2</td><td>Line 2, Col 3</td></tr>
    <tr><td>Line 3, Col 3</td><td>Line 3, Col 3</td></tr>
    </table>
    </body>
  </html>
} ]

See Also

[frame():]
[dialog():]
[dialog5():]
isFrameVisible()
Introduction to Dialogs and Frames
Forms tutorial
Whitelisted CDNs

Version Changes

  • 1.7.0 - Added scrollreset parameter option.