[TW5] - Is it possible to toggle a tag with a button?

966 views
Skip to first unread message

Ton Gerner

unread,
Dec 11, 2013, 2:48:52 PM12/11/13
to tiddl...@googlegroups.com
Hi all,

You can toggle a tag with a checkbox, but is it possible to toggle a tag with a button?

Why? See my usecase:

My guide "Top menu & toolbars" [1] shows a button (triangle top right) that toggles between the Snow White theme and the Hidden sidebar theme (that is also the limiting precondition: switching between these 2 themes).
The Hidden sidebar theme hides the sidebar and increases the tiddler width.
When I started with TW5 this seemed to be the simplest (for me achievable) solution for hiding the sidebar.

Triggered by the TaskManagementExample in TW5, I experimented with a style tiddler where the tag $:/tags/stylesheet could be toggled by a checkbox. I think a very easy solution.
As an example see [2] where the checkbox is positioned in the SiteSubtitle. Here only the tiddler width is increased and the sidebar shifted with the same amount to the right (if I hide the sidebar, I can't get it back ;) ).

In this way - say a checkbox in a top menu - you could toggle the sidebar independent of the theme used (assuming more or less "standard" themes).
It works - no complaints about that - but I do like a button in the toolbar of the top menu as in [1].

Is there a way to accomplish that: toggle a tag with a button?

Cheers,

Ton


[1] http://tw5toolbar.tiddlyspot.com/
[2] http://tongerner.tiddlyspot.com/

Stephan Hradek

unread,
Dec 11, 2013, 5:34:46 PM12/11/13
to tiddl...@googlegroups.com
Yes…

<$fieldmangler>
  <$list filter="[is[current]tag[MeTag]]">
    <$button message="tw-remove-tag" param="MeTag">remove MeTag</$button>
  </$list>
  <$list filter="[is[current]!tag[MeTag]]">
    <$button message="tw-add-tag" param="MeTag">add MeTag</$button>
 
</$list>
</$fieldmangler>



Ton Gerner

unread,
Dec 12, 2013, 3:46:39 AM12/12/13
to tiddl...@googlegroups.com
Hi Stephan,

Thanks a lot; that is exactly what I wanted.
Never thought of that strange named widget and even if I had thought of it, I could not have done it ;)

Thanks again.

Cheers,

Ton

Stephan Hradek

unread,
Dec 12, 2013, 6:22:30 AM12/12/13
to tiddl...@googlegroups.com


Am Donnerstag, 12. Dezember 2013 09:46:39 UTC+1 schrieb Ton Gerner:
Hi Stephan,

Thanks a lot; that is exactly what I wanted.
Never thought of that strange named widget and even if I had thought of it, I could not have done it ;)

Neither me. I just looked into the tiddlers which set and remove tags. They are buttons anyway.

Ton Gerner

unread,
Dec 12, 2013, 11:21:55 AM12/12/13
to tiddl...@googlegroups.com
Hi Stephan,

Just for the record.
I added your code - adapted to my case - to the Style 'wide' tiddler at [1].
Clicking the triangle toggle button accomplishes now the same as the checkbox in the SiteTitle.

Now I can simplify my 'toggle sidebar' button in my guide [2].

Thanks again.

Cheers,

Ton

[1] http://tongerner.tiddlyspot.com/
[2] http://tw5toolbar.tiddlyspot.com/

Leo Staley

unread,
Feb 12, 2014, 12:21:29 AM2/12/14
to tiddl...@googlegroups.com
Hey Stephan


On Thursday, December 12, 2013 4:22:30 AM UTC-7, Stephan Hradek wrote:

Neither me. I just looked into the tiddlers which set and remove tags. They are buttons anyway.

 How did you do that then? is there a list of which tiddlers can set and remove tags? are there other lists of tiddlers classified by functionalities like that?

Stephan Hradek

unread,
Feb 12, 2014, 2:27:22 AM2/12/14
to tiddl...@googlegroups.com


Am Mittwoch, 12. Februar 2014 06:21:29 UTC+1 schrieb Leo Staley:

 How did you do that then? is there a list of which tiddlers can set and remove tags? are there other lists of tiddlers classified by functionalities like that?

I just checked the edit templates because you can edit the tags when editing a tiddler.

Dmitry Skopa

unread,
Apr 8, 2015, 3:54:48 PM4/8/15
to tiddl...@googlegroups.com
Hello, Stephan

Could you please point me how to do the same inside a list?

Let's take a task list example:
<ul>
  <$list filter="[!is[system]tag[tasks]!tag[done]sort[-modified]]">
   
<li>
      <$button class="btn-invisible" message="tw-add-tag" param="done">Done!</$button>
      <$link to={{!!title}}><$view field="title"/></$link>
   
</li>
  </$list>
</ul>

The button "Done!" does nothing here. What should I change?

Danielo Rodríguez

unread,
Apr 8, 2015, 4:11:55 PM4/8/15
to tiddl...@googlegroups.com


El miércoles, 8 de abril de 2015, 21:54:48 (UTC+2), Dmitry Skopa escribió:
Hello, Stephan


The button "Done!" does nothing here. What should I change?

Probably because you are putting something into the param. This overrides the default parameter that is the tiddler title that should be affected by the message. This should be easier using action widgets. Which version of TW are you using?

Eric Shulman

unread,
Apr 8, 2015, 4:52:33 PM4/8/15
to tiddl...@googlegroups.com
On Wednesday, April 8, 2015 at 12:54:48 PM UTC-7, Dmitry Skopa wrote:
Let's take a task list example:
<ul>
  <$list filter="[!is[system]tag[tasks]!tag[done]sort[-modified]]">
   
<li>
      <$button class="btn-invisible" message="tw-add-tag" param="done">Done!</$button>
      <$link to={{!!title}}><$view field="title"/></$link>
   
</li>
  </$list>
</ul>
The button "Done!" does nothing here. What should I change?

1) change "tw-add-tag" to "tm-add-tag".  Since the original posting of the example, the prefix on core-defined messages was changed from "tw-" to "tm-". 
2) Similarly, you should also change "btn-invisible" to "tc-btn-invisible" because core-defined CSS class names now have a "tc-" prefix.
3) You also need to wrap the button inside a <$fieldmangler>...</$fieldmangler> widget.  This will 'catch' the tm-add-tag message sent from the button, and then add the tag value (the 'param' of the message) to the current tiddler.

let me know how it goes,

enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios

"Inside TiddlyWiki: The Missing Manual"
Note: the IndieGogo funding campaign has ended,
but direct fundraising continues below...

YOUR DONATIONS ARE VERY IMPORTANT!
HELP ME TO HELP YOU - MAKE A CONTRIBUTION TO MY "TIP JAR"...

Professional TiddlyWiki Consulting Services...
Analysis, Design, and Custom Solutions:

Dmitry Skopa

unread,
Apr 9, 2015, 1:47:08 AM4/9/15
to tiddl...@googlegroups.com
Thank you, Eric! It works!

Now I know what fieldmangler is for. I just thought button can do all the job. Like for setting filed value:
<$button set="!!status" setTo="completed">Complete!</$button>
Reply all
Reply to author
Forward
0 new messages