I get two color palatte to use one is light and the other is dark.
I want to use a command binding to shortcut to switch between the two. how to make it? Any hint will be ok. Thank you
I get two color palatte to use one is light and the other is dark.
I want to use a command binding to shortcut to switch between the two. how to make it? Any hint will be ok. Thank you
Have a look at the section on âUsing global Keyboard Shortcutsâ at https://tiddlywiki.com/
The active palette is saved in the tiddler $:/palette
Try this:
STEP 1: Create a tiddler named $:/config/shortcuts/switch-palette
, containing text:
ctrl-shift-X
This is the âkey bindingâ for your shortcut.
STEP 2: Create a tiddler named $:/config/ShortcutInfo/switch-palette
, containing text:
Switch between palettes
This is the description for your shortcut. The âswitch-paletteâ key binding will now be listed in the $:/ControlPanel
âKeyboard Shortcutsâ tab, which you use to quickly change the assigned key.
STEP 3a: Create a tiddler named $:/config/ShortcutActions/switch-palette
, tagged with $:/tags/KeyboardShortcut
, containing text:
<$set name="palettes" filter="[all[tiddlers+shadows]prefix[$:/palettes]]">
<$action-setfield $tiddler="$:/palette"
text={{{ [enlist<palettes>after{$:/palette}] ~[enlist<palettes>first[]] }}}/>
STEP 3b: Also in $:/config/ShortcutActions/switch-palette
, add a field named âkeyâ, with a value of:
((switch-palette))
This associates the indicated $action-setfield with the key binding defined in $:/config/shortcuts/switch-palette
.
With these three tiddlers defined, you can now press âctrl-shift-Xâ to cycle through all the defined palettes.
Note: to switch between just two specific palettes (e.g., âContrastDarkâ and âContrastLightâ), change the first line of $:/config/ShortcutActions/switch-palette
to:
<$set name="palettes" filter="[[$:/palettes/ContrastDark]] [[$:/palettes/ContrastLight]]">
enjoy,
-e
Thank you ~ But you seems miss the $:/tags/KeyboardShortcut
tag. Thanks a lot
Hi about this line of code [enlist<palettes>after{$:/palette}] ~[enlist<palettes>first[]]
What is the meaning of the ~
mark? I cant find the answer in the filter operator.
That is a filter run prefix, see https://tiddlywiki.com/#Filter%20Expression
In contemporary wikitext :else
is equivalent to ~
.