How to reverse cycle through the palettes using cycle operator

I am using a cycle palette button created by may be Mohammed (I saw it long back at the time of google groups, so not sure who created it).

I think it must be possible to reverse cycle through the palettes by using negative value in the cycle operator. How to do it by using a modifier key ?

You could make a second button to reverse, quite easity using an alternative actions +[cycle<pals>reverse[]] but untested.

  • Of note is if you dont have too many items you can by definition cycle back to the begining.
  • However to allow a modifier key to alter which action occurs chaNge the code so;
\define cycle-palettes()
<$set name=pals filter="[all[tiddlers+shadows]prefix[$:/palettes/Captivate]]">
<$action-listops $tiddler="$:/palette" $field="text" $subfilter="+[cycle<pals>]"/>
</$set>
\end

To include a modifier test, again untested.

\define cycle-palettes()
<$list filter="[<modifier>match[normal]]" variable=~>
<$set name=pals filter="[all[tiddlers+shadows]prefix[$:/palettes/Captivate]]">
<$action-listops $tiddler="$:/palette" $field="text" $subfilter="+[cycle<pals>]"/>
</$set>
</$list>
<$list filter="[<modifier>match[alt]]" variable=~>
<$set name=pals filter="[all[tiddlers+shadows]prefix[$:/palettes/Captivate]]">
<$action-listops $tiddler="$:/palette" $field="text" $subfilter="+[cycle<pals>reverse[]]"/>
</$set>
</$list>
\end
1 Like

@TW_Tones I tried your code here. But the reverse cycling with alt key is not working. Is it working for you?

To correct this, it is simply moving where you use the reverse operator,

Tested on your site and working

<$list filter="[<modifier>match[alt]]" variable=~>
<$set name=pals filter="[all[tiddlers+shadows]prefix[$:/palettes/Captivate]reverse[]]">
<$action-listops $tiddler="$:/palette" $field="text" $subfilter="+[cycle<pals>]"/>
</$set>
</$list>
  • From the subfilter to the definition of pals
1 Like

That is actually a nice approach using the stepsize parameter to cycle:

\whitespace trim
\define cycle-palettes()
<$let stepsize={{{ [<modifier>match[alt]then[-1]else[1]] }}}>
<$set name=pals filter="[all[tiddlers+shadows]prefix[$:/palettes/Captivate]]">
<$action-listops $tiddler="$:/palette" $field="text" $subfilter="+[cycle<pals>,<stepsize>]"/>
</$set>
</$let>
\end
2 Likes

Thank you @TW_Tones and @saqimtiaz . Both methods are working perfectly. Now I am confused which one to use. I will keep both of them in my wiki. It will be useful as a reference in the future.

@saqimtiaz I am hearing the term stepsize for the first time. Only reference I could fiind in the official site is this $:/core/modules/filters/x-listops.js.

Have a look at the operator documentation:
https://tiddlywiki.com/#cycle%20Operator

1 Like