Needed: a switcher macro

126 views
Skip to first unread message

David Gifford

unread,
Feb 27, 2020, 12:36:01 PM2/27/20
to TiddlyWiki
Hi all

Maybe this does exist, but I haven't seen it, and don't see documentation to create it.

The tiddlywiki.com documentation has stuff on how to create a 'toggle on-off' button with the checkboxwidget.

But there seems to be no documented way to choose from two or more options with checkboxes. That is, to switch themes, switch viewtemplates, switch palettes, etc, a series of options where if you choose one option, the other options are unchosen and turned off.

I am thinking, of course, of https://giffmex.org/gifts/tiddlyblink.html#%24%3A%2F.giffmex%2FViewToolbar%2Fviewrefscheckboxes. It would be nice to press one button instead of two, to switch between viewtemplates shown.

But having a tool like that, and documented on tiddlywiki.com, would also be helpful for switching between themes, palettes and stylesheets, just to name three other use cases. TiddlyBlink isn't the only time I have run up against this barrier.

In case anyone is up to something like that...

Thomas Elmiger

unread,
Feb 27, 2020, 3:51:32 PM2/27/20
to TiddlyWiki
Hi David,

If I got your idea right, you might want to use radio buttons instead of checkboxes:

All the best,
Thomas

David Gifford

unread,
Feb 27, 2020, 4:07:11 PM2/27/20
to TiddlyWiki
Thanks Thomas, but how would I use that for the kind of use cases am suggesting? There are no examples at that level, only brown tree frogs.

Thomas Elmiger

unread,
Feb 27, 2020, 5:10:16 PM2/27/20
to TiddlyWiki
Yeah, I see. You would have to change the whole logic.

At the moment you create a list of tiddlers:


... and manipulate one of them via checkbox (set/remove the viewtemplate tag). That’s fine for a list of tiddlers. You could use buttons instead that do the same PLUS remove the viewtemplate tag from all others. Note: Each button would need a list of all others for that.

To use radio buttons instead, you would need one new tiddler you can change via a set of radio buttons and where you store the title of the active template. The templates would always keep the viewtemplate tag.

In the view templates you would have to add a check, if the template is active. Something like this maybe:

<$list filter="***is this the active template?***>

   <$list filter="[!is[system]all[current]backlinks[]!tag[outlines]!tag[hide]sort[title]] -[is[current]]">
   ...
   </$list>
</$list>

I really should go to bed now, I hope you get the idea.

Mark S.

unread,
Feb 27, 2020, 5:14:08 PM2/27/20
to TiddlyWiki
@Thomas -- the radio button doesn't bind to tag fields, and doesn't have a documented action attribute (though I think all widgets inherit an action attribute).

@Dave

I think the technique I developed for this thread


could be adapted for your use. Basically, it binds the checkbox to a dummy field so the presentation is
controlled by the code and not by the relation. Then it uses checkaction and uncheckaction
to actually change tag state.

The question that immediately comes to mind is, won't there be times when you went
to see two reference presentations at once?

Thomas Elmiger

unread,
Feb 27, 2020, 5:24:08 PM2/27/20
to tiddl...@googlegroups.com
@Mark Well, the tag field is a field ... radios can handle a field. 
Did you see my last post? 



--
You received this message because you are subscribed to a topic in the Google Groups "TiddlyWiki" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tiddlywiki/SwSKmKxux9k/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tiddlywiki+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/22e7861c-c339-4a06-9a34-0ffba5783d87%40googlegroups.com.

Mark S.

unread,
Feb 27, 2020, 5:30:09 PM2/27/20
to TiddlyWiki
Our mails just missed each other by 4 minutes ;-)
To unsubscribe from this group and all its topics, send an email to tiddlywiki+unsubscribe@googlegroups.com.

David Gifford

unread,
Feb 27, 2020, 5:46:30 PM2/27/20
to TiddlyWiki
Thanks Mark and Thomas,

This is all still well beyond me, and not enough for tiddlywiki.com documentation to be complete, but thank you for your replies.
To unsubscribe from this group and all its topics, send an email to tiddl...@googlegroups.com.

Mark S.

unread,
Feb 27, 2020, 9:16:11 PM2/27/20
to TiddlyWiki

David Gifford

unread,
Feb 27, 2020, 9:35:05 PM2/27/20
to TiddlyWiki
Thanks Mark, but this seems to do what my checkboxes already do, correct?

Mark S.

unread,
Feb 27, 2020, 10:38:29 PM2/27/20
to TiddlyWiki
Except for that teensy detail, it's OK, right?

I should never try this before my 7th cup of coffee.

Ok, I think it's working now.

Mohammad

unread,
Feb 28, 2020, 3:06:26 AM2/28/20
to TiddlyWiki
This is another solution also by Mark in TW-Scripts


--Mohammad

TonyM

unread,
Feb 28, 2020, 4:31:24 AM2/28/20
to TiddlyWiki
David,

Here is an approach.

In a single tiddler define a button for each of your three or more states. One button shows the current state but clicking it selects the next state.

Now with list or reveal widgets wrap each button with a conditional display such that it only shows with the appropriate value(s) present.

All that will show is the button with the current state so it looks like one that changes a setting with one click.

If you are using a tag or field you may need to include another button or add another condition to display the first button even if no value is yet set.

Then transclude your button where needed {{||buttontiddler}} to act on the current tiddler.

You could tag it so it appears in a toolbar but a little more work is needed to provide captions and tootips.

Is this an approach you can use?

regards
Tony

David Gifford

unread,
Feb 28, 2020, 10:01:35 AM2/28/20
to TiddlyWiki
Hi everyone

Thank you all for your contributions and comments! I went with Mark S's solution. You can see it, modified, in either the 'eye' button at the top of the tiddlers, or the 'gear' sidebar tab, at https://giffmex.org/gifts/tiddlyblink.html.

I am not sure what would be the best way to document this on tiddlywiki.com. I will put a link somewhere in the toolmap later today. Eventually I will make a theme switcher and palette switcher with this, and will share the results. Blessings and thanks again!

Ton Gerner

unread,
Feb 28, 2020, 11:33:07 AM2/28/20
to TiddlyWiki
Hi David,

Why don't you use the core buttons for theme and palette switching?

$:/core/ui/Buttons/theme
$:/core/ui/Buttons/palette

You can just add an appropriate tag (e.g. $:/tags/ViewToolbar) or, if you don't want to override shadow tiddlers, transclude them in tagged tiddlers.

Cheers,

Ton

David Gifford

unread,
Feb 28, 2020, 11:36:33 AM2/28/20
to TiddlyWiki
because I didn't know they existed! :-)

Thanks for the heads up.

Ton Gerner

unread,
Feb 28, 2020, 11:48:40 AM2/28/20
to TiddlyWiki
Yeah, I am a button / toolbar maniac ;-)

Cheers,

Ton


Reply all
Reply to author
Forward
0 new messages