\define setFieldsDone()
<$action-setfield completed=<<now "YYYY-0MM-0DD hh:mm:ss">> />
<$action-setfield completedon=<<now "YYYY-0MM-0DD">> />
\end
\define setFieldsUndone()
<$action-setfield completed="" />
<$action-setfield completedon="" />
\end<$checkbox checked=<<setFieldsDone>> unchecked=<<setFieldsUndone>>>click me to mark this task done</$checkbox><$reveal type="match" state="!!temp" text="set">
<$button set="!!temp" setTo="reset">
<$action-setfield ..../>
<$action-setfield ..../>
Set</$button></$reveal>
<$reveal type="match" state="!!temp" text="reset">
<$button set="!!temp" setTo="set">
<$action-setfield ..../>
<$action-setfield ..../>
Reset</$button></$reveal><$reveal type="match" state="!!temp" text="set">
<$button set="!!temp" setTo="reset" class='tc-btn-invisible'>
<$action-setfield ..../>
<$action-setfield ..../>
<input type=checkbox/></$button></$reveal>
<$reveal type="match" state="!!temp" text="reset">
<$button set="!!temp" setTo="set" class='tc-btn-invisible'>
<$action-setfield ..../>
<$action-setfield ..../>
<input type=checkbox checked/></$button></$reveal>
I think I first saw that as a suggestion from Eric. Because of how updates work, modifying a checkbox widget to trigger action widgets doesn't always act the way you expect it to. I made a bunch of prototypes for other widgets triggering action widgets (you can see them here), the keyboard widget is the only one that has made it into the core due to the unexpected update behavior in the others. Even if that is fixed, having a checkbox widget that invokes action widgets would need something like what Matabele showed in order to have different actions for checking and unchecking.
Because of all that I think that the best idea is to fake a checkbox widget using buttons if you need more complex behavior.
Currently, action widgets can not be triggered with a checkbox widget (although some efforts have been made in this direction.)You may, however, use a button widget. If you wish to have visual feedback of the state -- use two button widgets within two reveal widgets which toggle one another off/on.
<$reveal type="match" state="!!temp" text="set">
<$button class="tc-btn-invisible" set="!!temp" setTo="reset">
<$action-setfield ..../>
<$action-setfield ..../>
<input type="checkbox">Set
</$button>
</$reveal>
<$reveal type="match" state="!!temp" text="reset">
<$button class="tc-btn-invisible" set="!!temp" setTo="set">
<$action-setfield ..../>
<$action-setfield ..../>
<input type="checkbox" checked="true">Reset
</$button>
</$reveal>
If you want the $button widgets to *look* like checkboxes:
<$reveal type="match" state="!!fakeCheckboxChecked" text="nope">
<$button set="!!fakeCheckboxChecked" setTo="yep" class="tc-btn-invisible">
<$action-setfield checkedtime=<<now "YYYY-0MM-0DD hh:mm:ss">> />
<$checkbox tag="tag me tagged">Check me!</$checkbox>
</$button>
</$reveal><$reveal type="match" state="!!fake" text="nope">
<$button set="!!fake" setTo="yep" class="tc-btn-invisible">
<$action-setfield checkedtime=<<now "YYYY-0MM-0DD hh:mm:ss">> />
<$checkbox tag="tag me tagged">Check me!</$checkbox>
</$button>
</$reveal>
<$reveal type="match" state="!!fake" text="yep">
<$button set="!!fake" setTo="nope" class="tc-btn-invisible">
<$action-setfield checkedtime="" />
<$checkbox tag="tag me tagged">Check me!</$checkbox>
</$button>
</$reveal>
{{!!checkedtime}}The value in 'checkedtime' toggles as expected, however the checkbox's have no effect?
<$reveal type="match" state="!!fakeCheckboxChecked" text="nope">
<$checkbox tag="tag me tagged">
<$button set="!!fakeCheckboxChecked" setTo="yep" class="tc-btn-invisible">
<$action-setfield checkedtime=<<now "YYYY-0MM-0DD 0hh:0mm:0ss">> />
Check me!
</$button>
</$checkbox>
</$reveal>
<$reveal type="match" state="!!fake" text="nope">
<$button set="!!fake" setTo="yep" class="tc-btn-invisible">
<$action-setfield checkedtime=<<now "YYYY-0MM-0DD hh:mm:ss">> />
<$action-listops $tags="[[tag me tagged]]"/>
<input type="checkbox">Check me!
</$button>
</$reveal>
<$reveal type="match" state="!!fake" text="yep">
<$button set="!!fake" setTo="nope" class="tc-btn-invisible">
<$action-setfield checkedtime=""/>
<$action-listops $tags="-[[tag me tagged]]"/>
<input type="checkbox" checked="true">UnCheck me!
</$button>
</$reveal>
{{!!checkedtime}}I think something like this will do the trick:
<$reveal type="match" state="!!fakecheckboxchecked" text="nope">
<$button set="!!fakecheckboxchecked" setTo="yep" class="tc-btn-invisible">
<$action-setfield checkedtime=<<now "YYYY-0MM-0DD 0hh:0mm:0ss">> />
<$action-sendmessage $message="tm-add-tag" param="tag me tagged" />
<input type="checkbox" />Check me!
</$button>
</$reveal>
<$reveal type="match" state="!!fakecheckboxchecked" text="yep">
<$button set="!!fakecheckboxchecked" setTo="nope" class="tc-btn-invisible">
<$action-setfield checkedtime="" />
<$action-sendmessage $message="tm-remove-tag" param="tag me tagged" />
<input type="checkbox" checked />Uncheck me!
</$button>
</$reveal>Thanks, Matabele! That does the trick in TiddlyWiki 5.1.10, all right!In 5.1.9 (where I'd been playing around with this), it looks like the <$action-listops> macro isn't part of the core.
Just FYI, I tried using <$action-sendmessage> with tm-add-tag and tm-remove-tag, to no avail. Clearly I'm misunderstanding/misusing that widget ...
Just FYI, I tried using <$action-sendmessage> with tm-add-tag and tm-remove-tag, to no avail. Clearly I'm misunderstanding/misusing that widget ...Wrap your button inside a <$fieldmangler>...</$fieldmangler>. This will catch the tm-add-tag and tm-remove-tag messages and update the tags field accordingly (adding/removing the tag from the existing tag list value).
<$button>
<$action-listops tiddler="Target Tiddler" $tags="[[Tag to Add]] -[[Tag to Remove]]"/>
Tag</$button><$button>
<$action-listops $tiddler="Target Tiddler" $tags="AddTag AndAnother -RemoveTag -RemoveAnotherTag"/>
Tag</$button><$fieldmangler tiddler="Target Tiddler">
<$button>
<$action-sendmessage $message="tm-add-tag" $param="AddTag"/>
<$action-sendmessage $message="tm-add-tag" $param="AndAnother"/>
<$action-sendmessage $message="tm-remove-tag" $param="RemoveTag"/>
<$action-sendmessage $message="tm-remove-tag" $param="RemoveAnotherTag"/>
Tag</$button>
</$fieldmangler><$button>
<$action-listops $tiddler="Target Tiddler" $tags="+[prefix[$:/]] MyNew Tags"/>
Tag</$button><$action-listops $field="my-field" $subfilter="+[additional[filter run]]"/><$action-listops $field="my-field" $filter="[list[!!my-field]] +[additional[filter run]]"/>On 14 January 2016 at 7:36:06 PM, Scott Simmons (Secret-HQ) (goo...@secret-hq.com) wrote