Mask-closable, how to use in a macro?

I tried this and it doesn’t work. I click outside of the modal and the modal stays open. What am I doing wrong?

\define moreinfo(tid) @@.donotprint &nbsp;<$button class="tc-btn-invisible" message="tm-modal" param="$tid$" mask-closable="true">^^{{$:/core/images/open-window}}^^</$button> @@

“mask-closable” is not a parameter, it is a field you must set in the modal tiddler itself.
If you want to make sure any modal tiddler is mask-closable, you can use <$action-setfield> to set the field to true before opening the modal.

Fred

1 Like

The mask-closeable flag should be set as a field in the tiddler to be displayed.
Thus, your $button widget need to use $action-setfield to add that field/value to the tiddler to be displayed.
To avoid directly changing that tiddler, you can use a $:/temp/... tiddler, like this:

\define moreinfo(tid)
\define temp() $:/temp/modal/$tid$
@@.donotprint &nbsp;
<$button class=tc-btn-invisible message=tm-modal param=<<temp>>>
   ^^{{$:/core/images/open-window}}^^
   <$action-setfield $tiddler=<<temp>> subtitle="$tid$" text={{$tid$}} mask-closable=yes/>
</$button>@@
\end

enjoy,
-e

2 Likes

Thank you so much, Fred and Eric! Eric, your solution works beautifully! Thanks!

Addendum:

The solution I provided copies the text field from the “target” tiddler to the $:/temp/modal/... tiddler.
This works just fine, unless that tiddler content depends upon other fields from the same target tiddler.

To handle that situation, change this line:

   <$action-setfield $tiddler=<<temp>> subtitle="$tid$" text={{$tid$}} mask-closable=yes/>

to these two lines:

   <$action-setfield $tiddler="$tid$" title=<<temp>>/>
   <$action-setfield $tiddler=<<temp>> subtitle="$tid$" mask-closable=yes/>
  • The first line effectively copies ALL of the fields from the target tiddler to the temp tiddler (without even needing to know what those fields are!). This works because setting the title of the target tiddler doesn’t actually change the title of that tiddler but simply creates a new tiddler with the specified title and the same fields and values as the original tiddler.
  • The second line then adds the subtitle and mask-closeable fields used by the modal display.

-e

3 Likes