On Tuesday, February 23, 2021 at 3:39:31 AM UTC-8 Ste wrote:

> \define HelpButton(label, ButtonText:?)
> ^^(<$button popup="""$:/temp/popup/$(currentTiddler)$/$label$""" 
> class='tc-btn-invisible tc-tiddlylink'>$ButtonText$</$button>)<$reveal 
> type='popup' state="""$:/temp/popup/$(currentTiddler)$/$label$"""><div 
> class='tc-drop-down' 
> style='width:1500px;max-width:75vw;white-space:pre-wrap;padding:10px;text-align:left;font-size:1.5em;border-radus:0.5em;'><$transclude
>  
> field="""$label$"""/></div></$reveal>^^
> \end
>
Now, I have a tabs list:
>
<<tabs tabsList:"[[tiddler1]] [[tiddlertwo]] " class:"tc-vertical">>
> ...the help button shows when in the tabbed list but works perfectly in 
> the original tiddler.
>

The problem arises because popup's "state" tiddler (
$:/temp/popup/$(currentTiddler)$/$label$) depends on the value of 
$(currentTiddler)$.

In the "original" tiddler, this value is the title of that tiddler.  
However, when shown in a tab, the value is the title of the tiddler 
containing the entire tab set, rather than the title of the tab content 
tiddler itself.

As explained in https://tiddlywiki.com/#tabs%20Macro:
*The currentTiddler variable is not affected by the tabs macro. This can 
put you in trouble if the list of tabs includes tiddlers that depend on the 
value of the currentTiddler,*

One way to account for this is to wrap your macro within a $tiddler widget, 
like this:
<$tiddler tiddler=<<currentTab>><<HelpButton ...>></$tiddler>

What this does:
* when the content is shown in the "original" tiddler, the value of 
<<currentTab>> is undefined, so the $tiddler widget has no effect
* when the content is shown in a tab, the value of <<currentTiddler>> is 
set to the same as the <<currentTab>>

Note that, to make this usage a bit cleaner, you could re-write your code 
as follows:
\define HelpButton(label, ButtonText:?) <$tiddler 
tiddler=<<currentTab>><<HelpButton_inner $label$ $ButtonText$>></$tiddler>
\define HelpButton_inner(label, ButtonText:?)
^^(<$button popup="""$:/temp/popup/$(currentTiddler)$/$label$""" 
class='tc-btn-invisible tc-tiddlylink'>$ButtonText$</$button>)<$reveal 
type='popup' state="""$:/temp/popup/$(currentTiddler)$/$label$"""><div 
class='tc-drop-down' 
style='width:1500px;max-width:75vw;white-space:pre-wrap;padding:10px;text-align:left;font-size:1.5em;border-radus:0.5em;'><$transclude
 
field="""$label$"""/></div></$reveal>^^
\end

The first macro adds the $tiddler wrapper and then invokes the actual 
HelpButton code (now renamed HelpButton_inner)

enjoy,
-e

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/00331954-0dea-490d-9e4a-af90e396495dn%40googlegroups.com.

Reply via email to