uniquified slider (reveal) macro not working

111 views
Skip to first unread message

Dave

unread,
Dec 4, 2018, 12:29:46 AM12/4/18
to tiddl...@googlegroups.com
I thought that I was clever to make a slider macro/reveal widget that stored its state in a unique spot related to just the tiddler it was in:

\define slider(label,text)
<$set name=this value=$(currentTiddler)$ >
<$button popup="$:/state/<<this>>$label$" class="btn-invisible tw-slider">$label$</$button>
<$reveal type="nomatch" text="" default="" state="$:/state/<<this>>$label$" animate="yes">

$text$

</$reveal></$set>
\end

<<slider "*" "hello there">>


but when I put "<<slider "*" "hello there">>" in two separate tiddlers, they both open when I click on either of them.  If I change the "*" to something different in the second one, like "**" they stay separate, but I thought the use of <<this>> (whose value=$(currentTiddler)$) would put the state in different places because the tiddlers are named differently.

What am I doing wrong here?


thanks,
- Dave


Mohammad

unread,
Dec 4, 2018, 12:42:03 AM12/4/18
to TiddlyWiki

Jed Carty

unread,
Dec 4, 2018, 2:05:33 AM12/4/18
to TiddlyWiki
For reasons that have to do with how the macro parser works that I don't think I can explain in an understandable way right now your set widget is the problem.

try using this macro instead:

\define slider(label,text)
<$button popup="$:/state/$(currentTiddler)$$label$" class="btn-invisible tw-slider">$label$</$button>
<$reveal type="nomatch" text="" default="" state="$:/
state/$(currentTiddler)$$label$" animate="yes">


$text$


</$reveal>
\end


<<slider "
*" "hello there">>

the quick thing is that $(variable)$ is a direct text substitution and <<variable>> doesn't work the same way. if you look at the state tiddler created using yours it is literally called $:/state/<<this>>* without the <<this>> part being substituted.

Dave

unread,
Dec 4, 2018, 10:29:39 AM12/4/18
to TiddlyWiki
Thank you Jed (and Mohammed)

I'm glad the reason mine didn't work was convoluted... That way I don't feel so bad for getting it wrong, ha ha

RA

unread,
Dec 20, 2018, 2:03:17 AM12/20/18
to TiddlyWiki
I tried this code. After the slider is revealed, as soon as I click anywhere, it hides back. Is that how this is supposed to work?

Dave

unread,
Dec 20, 2018, 2:12:17 AM12/20/18
to TiddlyWiki
Yes :)


I think there are ways to have it stay open if you want, but I'm not at my computer right now to figure that out

RA

unread,
Dec 20, 2018, 4:09:53 AM12/20/18
to TiddlyWiki

I think I have figured that out in the past, here is the code that I re-discovered in my own wiki. (If you have FontAwesome, you can delete "tc-btn-boxed","show", and "hide" from the example.)


\define sliderButtonClasses() tc-btn-invisible tc-btn-boxed

\define sliderState(contentTiddlerTitle stateTiddlerPath:"$:/state/slider/")
$stateTiddlerPath$$contentTiddlerTitle$
\end

\define slideThis(tiddler)
<$reveal type="nomatch" state=<<sliderState '$tiddler$'>> text="show">

<$button set=<<sliderState '$tiddler$'>> setTo="show" class=<<sliderButtonClasses>>
><span class="fas fa-fw fa-plus"/>show</$button><$link to={{$tiddler$!!title}}><$view tiddler='$tiddler$' field="caption">{{$tiddler$!!title}}</$view></$link>

</$reveal>
<$reveal type="match"   state=<<sliderState '$tiddler$'>> text="show">

<$button message="tm-delete-tiddler" param=<<sliderState '$tiddler$'>> class=<<sliderButtonClasses>>
><$action-deletefield $tiddler=<<sliderState '$tiddler$'>> $field=text/
><span class="fas fa-fw fa-minus"/>hide</$button><$link to={{$tiddler$!!title}}><$view tiddler='$tiddler$' field="caption">{{$tiddler$!!title}}</$view></$link>

<<<
{{$tiddler$}}
<<<
</$reveal>
\end


<<slideThis "$:/
HistoryList">>
Reply all
Reply to author
Forward
0 new messages