Checkbox actions question

104 views
Skip to first unread message

Hubert

unread,
Jul 27, 2018, 4:57:47 AM7/27/18
to TiddlyWiki
Hi all,

We can now assign actions to checkboxes that will be triggered when checking/unchecking the checkbox, as in this example.

It seems that (by design?) the same assigned set of actions will be triggered whether the checkbox is checked or unchecked.

Has anyone found a way to assign a different set of actions depending on whether the checkbox is checked or unchecked (one set of actions for 'checked', another one for 'unchecked')?

Thank you!

Mark S.

unread,
Jul 27, 2018, 10:09:32 AM7/27/18
to TiddlyWiki
Since the checkbox flips the state field before calling actions, you could use a reveal widget to limit the actions to either one state or the other. Like:

\define myactions()
<$reveal state="mystate!!checked" type="match" text="YES">
<$fieldmangler>
<$action-setfield  $field="tags" $value=<<tag>> /><$action-sendmessage $message="tm-add-tag" $param=<<tag>> />
</$fieldmangler>
</
$reveal>
\end

<$set filter="[[Features]] [[Encryption]] +[tags[]]" name="tag">
<$checkbox actions=<<myactions>> tiddler="mystate" field="checked" checked="YES" unchecked="NO" >
   
Add tags from tiddlers [[Features]] and [[Encryption]]
</$checkbox>
</
$set>

It seems to work in my tests. On the first click it sets the tags as expected. Open the tiddler. Delete the tags. Close the tiddler Now uncheck the box, and tags are not added back.

-- Mark

Hubert

unread,
Jul 27, 2018, 10:18:16 AM7/27/18
to TiddlyWiki
Thank you Mark for your great help, again! Much appreciated.

Best regards,
Hubert
Reply all
Reply to author
Forward
0 new messages