It seems in this case there are other simple solutions too, while in my
opinion toggle is the most semantic one but in its current implementation
is tricky to use for toggling a field can be changed outside the script.

These are other solutions that do not use toggle but very simple.  Of
course simple is the best but not simpler.

*!! Simple solution*

<$button>Day/Night
<$list
filter="[{$:/palette}match[$:/palettes/Vanilla]then[$:/palettes/SolarFlare]else[$:/palettes/Vanilla]]">
<$action-setfield $tiddler="$:/palette" text=<<currentTiddler>>/>
</$list>
</$button>


*!! Good practice*

<$vars
   lightPalette="$:/palettes/Vanilla"
   darkPalette="$:/palettes/SolarFlare"
>
<$button>Day/Night II
<$list
filter="[{$:/palette}match<lightPalette>then<darkPalette>else<lightPalette>]"
variable=selectedPalette>
<$action-setfield $tiddler="$:/palette" text=<<selectedPalette>>/>
</$list>
</$button>
</$vars>


You may read *darkPalette *and *lightPalete *from a config tiddler fields.

Best wishes
Mohammad


On Mon, Dec 14, 2020 at 4:14 PM Mohammad Rahmani <[email protected]>
wrote:

> I use the below button to toggle between day/night palette
>
> <$button>Day/Night
> <$action-listops $tiddler="$:/palette" $field="text" 
> $subfilter="+[toggle[$:/palettes/Vanilla],[$:/palettes/SolarFlare]]" />
> </$button>
>
> The problem here is if $:/palette is not empty and has not one of the two
> values above, then I get the wrong values in the text field (actually the
> value is appended). How can I replace the field value using toggle operator.
>
>
>
> Best wishes
> Mohammad
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/CAAV1gMB0HOwt-uFD%2B7RHwpjjTsoq6q1RMLJ0NCOKKr8ZMd3WgQ%40mail.gmail.com.

Reply via email to