Conditional display of viewtoolbar buttons

I would like display only certain viewtoolbar buttons for certain tiddlers based on the presence of tags or fields. How to approach this ?

I also want to limit the number of viewtoolbar buttons visible in mobile. I should look at the JD’s mobile plug in for ideas I guess.

The best way I have found is to hide buttons behind the more button then clone the buttons you want to add conditionality to.

  • inside your cloned buttons wrap the button code in a list widget using the filter as a condition.

Just ask if you want me to demonstrate

1 Like

Thats sounds like a good approach…I will try my luck first and will ask for help if needed. Thank you @TW_Tones for the tip.

The toolbar tiddlers are tageed: $:/tags/EditToolbar and they have a condition and a condition-disabled field.

Both fields contain filters, with which you can define the behaviour. …

Every toolbar button has a “visibility” config tiddler $:/config/EditorToolbarButtons/Visibility/<button-name>

They are independent of the core button tiddlers, if you don’t want to change the conditions.

3 Likes

There is a docs tiddler which may be interesting: https://tiddlywiki.com/#How%20to%20create%20dynamic%20editor%20toolbar%20buttons

To be clear the OT mentions viewToolbar buttons, not EditorToolbar buttons.

  • Perhaps this feature could be added to all core buttons?
    • but it will add even more complexity.
  • Of course to hide totally any button from use, such as one you created a conditional version of you can remove its $:/tag/..

Alternatively I wondered if we could co-opt the current visibility mechanism to allow a filter in the visibility tiddler? rather than show/hide or yes/no

  • We may need to change it from a reference to a transclude in the core tiddlers.
  • Once working the user/designer just modifies the visibility tiddler, to return the appropriate value show/hide.
  • We may need to alter the view toolbars UI

uups. Sorry but the mechanism is exactly the same

  • Are you saying we can add condition and a condition-disabled fields to any button to do this already?
    • If so I am amazed I did not stumble on this before now
    • However the clone of core buttons and hide behind more still work nicely with this.

Had to look at the code. Visibility is there. The conditions have been discussed, but it seems never been implemented. Sorry for the confusion.

The reason I was quick to answer is I recently did exactly this in this How to inhibit edit on tiddlers - ease of use feature

@TW_Tones I used a filter to limit the viewtoolbar button to be shown only on certain tiddler.

1 Like

@TW_Tones I used this method which you discussed elsewhere (I am unble to find that post now) and created a viewtoolbar button similar to the more button.

Press on this button on this tiddler.

image