Help with $radio and $reveal (more precisely with the "state" attribute)

Hi, I was working with an EditorToolbar button whose dropdown I wanted to have two or more states handled with a $radio widget, to switch between them.

I don’t like defining an external state tiddler when it’s not needed (maybe it’s a bad habit, but in this in this isolated case I wanted to use a field to store information about the state of the $radio)
-So:

<$tiddler tiddler="$:/sob/EditorToolbar/Dropdown/x">
<$radio field="radio" value="1">&thinsp;Page1</$radio>&nbsp;
<$radio field="radio" value="2">&thinsp;Page2</$radio>
</$tiddler>

No problem so far.

But when I came to define a $reveal that uses the value of the “radio” custom field (“1” or “2”) I got stuck.

I recalled that the documentation listed more than one way to define the state of the $reveal widget:
https://tiddlywiki.com/#RevealWidget
In fact, here is the “stateField” attribute, which, based on the name, seems to be useful for my case. The documentation explains that:

A field name which is used to look for the state, if the attribute stateTitle is present

And about the “stateTitle”

A title containing the state, without TextReference. Gets preferred over the state attribute


So based on what I did understand here is what I tried:

<$reveal stateTitle="$:/sob/EditorToolbar/Dropdown/x" stateField="radio" type="match" text="1" animate="yes">

{{$:/sob/EditorToolbar/Dropdown/x/page1}}

</$reveal>

<$reveal stateTitle="$:/sob/EditorToolbar/Dropdown/x" stateField="radio" type="match" text="2" animate="yes">

{{$:/sob/EditorToolbar/Dropdown/x/page2}}

</$reveal>

But nothing is shown, regardless of the value of the “radio” field.

I must have done something wrong. Unfortunately the documentation about “stateTitle” and “stateField” stops there, and among the examples, there are none that use them. Nor have I found examples online that use them.


  • Could you tell me where I went wrong?

I am not sure the cause of your problem but this minor variation that works with current tiddler does work as expected;

<$radio field="radio" value="1">&thinsp;Page1</$radio>&nbsp;
<$radio field="radio" value="2">&thinsp;Page2</$radio>

<$reveal stateTitle=<<currentTiddler>> stateField="radio" type="match" text="1" animate="yes">

[[page1]] {{page1}}

</$reveal>

<$reveal stateTitle=<<currentTiddler>> stateField="radio" type="match" text="2" animate="yes">

[[page2]] {{page2}}

</$reveal>

:thinking:

This is strange. I tried with your solution and it worked immediately. I then tried redefining out of curiosity again like I had done before stateTitle="$:/sob/EditorToolbar/Dropdown/x" and it still worked. Did I make a syntax error? (It seems strange to me because I usually copy and paste titles and stuff like that)

Or it could be that in the meantime, before your answer, I had also reloaded the wiki, maybe I had done something before and reloading fixed it (?)

Idk. In any case, it works now, thank you @TW_Tones!

Assuming that you have 2 tiddlers, named:

$:/sob/EditorToolbar/Dropdown/x/page1

and

$:/sob/EditorToolbar/Dropdown/x/page2

with content to show, your posted code does work: