Checkbox widget with custom icon or a button

70 views
Skip to first unread message

Mohammad

unread,
Aug 10, 2018, 2:51:29 AM8/10/18
to TiddlyWiki
I want to use the checkbox widget for toggling a field on/off or true/false


How can I have a custom button (or custom graphics) instead of simple checkbox icon?

There is a macro developed by Mat: http://toggle.tiddlyspot.com/  can do this but I want to do this with TW checkbox included in the core!

Is there any solution to do that?

Note I want to use it to simple toggle a field on/off! Standard button cannot simply do that!



Mohammad

PMario

unread,
Aug 10, 2018, 2:57:30 AM8/10/18
to TiddlyWiki
On Friday, August 10, 2018 at 8:51:29 AM UTC+2, Mohammad wrote:
I want to use the checkbox widget for toggling a field on/off or true/false


How can I have a custom button (or custom graphics) instead of simple checkbox icon?

You'd probably need to use custom CSS styles.


-m

Mohammad

unread,
Aug 10, 2018, 3:05:18 AM8/10/18
to tiddl...@googlegroups.com
Mario,
 It accepts  a class parameter, but it applies to label not icon!

Mohammad

TonyM

unread,
Aug 10, 2018, 4:58:43 AM8/10/18
to TiddlyWiki
Mohammad,

You need to create a two button system where one only shows if the other does not.

Actually I have being through a few repetitions to develop this method;

here is an example ripped from my current work.
\define ea-toggle()
<$list filter="[is[current]has[view-caption]">
{{!!view-caption}}
</$list>
<$list filter="[is[current]!edit-view-caption[yes]]">
<$button set="!!edit-view-caption" setTo="yes" class="tc-btn-invisible">
{{$:/
core/images/edit-button}}
</$button>
</
$list>
<$list filter="[is[current]edit-view-caption[yes]]">
{{||$:/PSaT/Viewer/edit-view-caption}}
<$button set="!!edit-view-caption" setTo="no" tooltip="save and set view-caption" class="tc-btn-invisible">
{{$:/core/images/done-button}}
</$button>
</
$list>
\end


Notice how the filter to display each button is a simple negation of the other, and the !edit-view-caption[yes]]
Helps deal with the state field not existing in addition to the no state.

Of course you could use two checked and unchecked icons but the checkbox widget does that well.

I trick I found recently was to use a special character rather than an icon https://www.w3schools.com/charsets/ and allow the selected state to simply underline the character.
eg ☏ and

Regards
Tony

Mohammad

unread,
Aug 10, 2018, 5:55:02 AM8/10/18
to TiddlyWiki
Hi Tony!
Good idea! Using list and buttons versus reveal and buttons!

 It works for me and changing the icons is simple!

Any action macro can be used with the buttons.

By the way I understood the checkbox in the core is not customizable  as we like!

/Mohammad

PMario

unread,
Aug 10, 2018, 7:10:11 AM8/10/18
to TiddlyWiki
On Friday, August 10, 2018 at 11:55:02 AM UTC+2, Mohammad wrote:

By the way I understood the checkbox in the core is not customizable  as we like!

I think, that's just because nobody did create a pull request yet and the feature requests most of the time are for very specific usecases.

For the core, we need something, that is generic enough to be used for many different usecases. ...

It needs to be "just good enough" to be useful by default and it "needs to go out of the way" if users want to tweak it.

-m
Reply all
Reply to author
Forward
0 new messages