Just a minor thing for anyone else, Eric's awsome solution is missing a > 
after <$tiddler tiddler=<<currentTab>> so it should be <$tiddler 
tiddler=<<currentTab>>> and works like a charm!  Thanks once again.

On Tuesday, 23 February 2021 at 16:37:34 UTC Ste wrote:

> Thank you Eric,
> Much appreciated.  I had thought it might be the words 'current tiddler'  
> but had no clue what to do about it!
>
> On Tuesday, 23 February 2021 at 14:23:23 UTC Eric Shulman wrote:
>
>> 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/74b93e02-2692-4503-8440-d1dd11331589n%40googlegroups.com.

Reply via email to