Hallo everyone,
how do I add to tiddlers’ toolbar a custom button that opens a dropdown list of choices when clicked? So far I was able, thanks -or I should rather say despite- to TW documentation’s page ‘Creating new toolbar buttons’ ( https://tiddlywiki.com/static/Creating%20new%20toolbar%20buttons.html ) to add a custom button to the toolbar. Now how do I make it open a dropdown list of choices as is the case of default ‘More actions’ button?
Perhaps the easiest way is to copy a button that already does this. I am sure there are reasons, some historical, some related to multi-language support that such buttons are awkward to follow.
What is the function of the button you want to build or is this only a general question? I ask because what if it exists already?
I recently cloned the Editor Tollbar button “excise” to do this,
see New EditorToolbar button "wrapper" please review - #3 by TW_Tones look for the latest shared, and I have done view toolbar buttons previously including cloning the more button for a drop down list. Once you cloan it you have to review tags, fields and field values, replacing values or creating additional tiddlers.
Because of the effort involved my new button will serve as a template for future Editor Toolbar buttons.
I will try, time permitting to do a new view toolbar button with drop down and share that soon. Keep an eye on the discussion thread. It may then be easy to clone my button than a core one to build another.
a completely general question, I need to implement this button to show a dropdown of my own custom actions, no way for these to already exist somewhere…
By the way, it would be useful to add a little tutorial page on the subject in the official TW documentation.
“to show actions” is hard to understand. Actions is whatever you make them and you could list a bunch of buttonwidgets that perform actions. But assuming you mean “show my items” then here’s a template for you:
In my above solution you can place anything you want to appear in the dropdown in one or more tiddlers. So if you have a button with an action already just give it the matching tag.
OK, I think you must use the MessageCatcher widget then. It was a long time ago that I fiddled with that, so I can’t tell how it is used right away. If you investigate how the “more” tiddler tool button is created I think you should find use of it and can study it. Or elsewhere.
…or maybe it is just a matter of making your items in the list be ButtonWidgets. You can style the buttons to look like links (by applying tc-btn-invisible tc-tiddlylink) or just like text.
Add the tag $:/tags/more-ViewToolbar to any tidler or an existing button and it will appear in that menu drop down (What ever displays in the text field
You asked for
list of choices when clicked?
I always wanted this for myself but I made it now for you. Please take the time to consider an Ernest reply to you and with respect try a little harder to work it out. Always feel free to ask questions but please put in the effort.
In this solution a Tiddler with the $:/tags/more-ViewToolbar tag can contains one or more buttons that triggers whatever actions you are interested in.
The key advantages of this implementation is that
Out of the box just tag tiddlers to get them to appear in the dropdown
This drop down button is a full member of the view Toolbar buttons and appears in the control panel > Appearance > Toolbars and can be moved behind the more button
the $:/PSaT/buttons/more-tiddler-actions can be cloned an edited to create additional dropdowns.
Thanks for sharing, I feel grateful indeed and I put all the effort I could, but it just doesn’t seem to go the way it should. When I do the import, all I see is this…
Thank you, now that I found how to correctly import it I tested it and it does [almost] exactly what I was looking for. Now I only have to hack it just a little, to make it ‘contextual’, so for it to show up only on certain tiddlers, not all…
Can you point me to the code to modify? I’m not asking you to spend time hacking it for me, just tell me please where do I go in your code to add my changes.