So I’m making a blackout palette that pairs with an edit of the tag macro tiddler, and I was planning to use the reveal widget to only show the changes to the tag macro when the specific palette was used, forgetting that if a definition isn’t on the first line, it won’t really work…
I’d like to either hide the text or remove the $:/tags/Macro if $:/palettes/Dark isn’t the selected palette, and not needing a button.
Does anyone have any suggestions?
It would need more research, but in the core code where you select the pallet, you could add some additional actions, if matches $:/palettes/Dark then add the tag $:/tags/Macro to your desired tiddler, if not remove it.
Then this macro tag will be set for your desired pallet and remove for all others.
This occurs in $:/core/ui/ControlPanel/Palette then $:/snippets/paletteswitcher
In $:/snippets/paletteswitcher it uses a link catcher rather than buttons, and the link catcher widget has an actions parameter.
That might be above my skill level, as I don’t really know how to use the linkcatcher to do what I aim to, and not entirely sure how $:/snippets/paletteswitcher is doing what it does.
This might be above my skill level as of right now, I might need to revisit this after tinkering with the link catcher widget
Adjust the \define macrosTitle() in the example above to your new name
Adjust the \define paletteTitle() to your palette name
I did use Spartan Night for easy testing with tiddlywiki.com
That should do the trick. The following JSON file contains 3 tiddlers
custom-palette-actions … The macros to add and remove the $:/tags/Macro tag
your macro tiddler not core … Your macors with a new name
$:/snippets/paletteswitcher … The modified core snippet
Ah oops ok, I just suffixed it with oled for temporary titling, ive been using $:/wiki/… for most of my tweaks, I’ll make sure to change it when I get back to my computer, as of right now I’m phone bound while waiting for triple A
It may be awhile before I’m able to try this code snippet, i knew that the reveal widget wouldnt likely work, but wasn’t quite sure of any other methods for dynamically showing and removing tiddlers without* manual use, like buttons using actions, so that one’s on me, but I’m glad this is indeed possible without the use of something like custom javascript or anything like that.
Edit:
OK, so that works perfectly! Sadly I made a bit of a hiccup with my changes to the tag macro change, but otherwise this is perfect, thank you everybody
Small note, I did find out the tag being applied was $:/tag/Macro, which should be $:/tags/Macro, for anyone trying this and having trouble, I forgot to point that out, I just fixed it when I saw it
That was intentional to test your participation – Just joking.
I did update the code and the JSON attachment accordingly. So it should work with the right tags now
I try to when I can, I still have plenty to learn though, mind if I ask how the linkcatcher widget functions? Is it like a button where if any link that matches is clicked on it activates?
I noticed it works both for the palette switcher sidebar button and the palette selector in the control panel
If you click a link in TW the core emits a tm-navigate message with a “navigate to tiddler” information. This and only this message is “intercepted” by the linkcatcher widget.
The linkcatcher has an actions parameter, which can be used to do something user specific, instead sending the message to the navigator widget. That’s the version we use here.
There are several other possibilities. Eg: the to parameter writes the “navigate to tiddler” title into a tiddler specified with the to-parameter. That’s the default action that can be seen in the $:/snippets/paletteswitcher
So if actions and to are defined it will do both. That’s what we did with our code as described in my first post.
That’s because the 2 sections of the UI use the same code snippet. In the UI we try to re-use the code for the same actions.