On Saturday, August 20, 2016 at 2:56:02 AM UTC+2, David Someone wrote:
>
> I think I've figured out what it does...
>

\o/ 

// define a text substitution macro that allows us to handle tiddler names, 
that contain spaces. 
// this one took me an hour to get it right :/

\define tagWithSpaces()[[$(myTag)$]]

// define the macro named: tagButtons, that gets a "tag" parameter
\define tagButtons(tag)

// Make a list of Tiddlers tagged with $tag$, which aren't drafts
// $tag$ is replaced with: color   see usage: <<tagButtons tag:color>>
// myTag is a loop variable where the list widget stores at actual tiddler 
name, 
//   that is tagged: color see: http://tiddlywiki.com/#ListWidget

<$list filter="[tag[$tag$]] -[has[draft.of]]" variable="myTag">

  // Output the list as button widgets
  // there are some core classes, that you can use to hide buttons eg: 
tc-button-invisible

  <$button class="tc-button-invisible">

  // When the button is clicked, make a temp Tiddler with these tags in a 
field called "list"
  // ... absolutley right :)

  <$action-listops $tiddler="$:/temp/myTags" $field:list 
$subfilter="[tag[$tag$]] -[has[draft.of]]"/>

  // Take the current Tiddler (where this is called from) and tag it 
  // with a list with the tags from the list in the temp Tiddler removed, 
and
  // tagWithSpaces (which is myTag) appended. 
  // .... right. first remove eg: red, green, blue  ... then append the 
one, that was clicked.

  <$action-listops $tiddler=<<currentTiddler>> 
$tags="+[remove{$:/temp/myTags!!list}append<tagWithSpaces>]" />

  <<myTag>>
  </$button>

</$list>
\end

--------------

\define tagWithSpaces()[[$(myTag)$]]   if you try this

\define tagWithSpaces() $(myTag)$

and use a tiddler name "with spaces" tagged: color and you apply the tag, 
you'll see what's going wrong. it adds 2 tags "with" and "spaces" instead 
of "with spaces" ... 


Next step is to reset the "class" of the buttons to "off", then set the 
> "class" of the button I've clicked to "on". 


See tc-xxxx classes in tw help and my code above.  
Adding style sheets is easy. Just create a tiddler eg: myStyles and tag it: 
$:/tags/Stylesheet
It needs to contain valid CSS code. 


This is why I'm thinking it would have been easier to write a widget in 
> JavaScript than to write a macro in TW. 


No. No way. 
 

> Again, totally impressed, but equally stumped! At least I'm learning!!


Glad you take the time :)

-mario 

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywikidev+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywikidev@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywikidev.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywikidev/edbd9db9-185f-4723-9775-38454db63dd4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to