Keyboard Shortcut to show/hide edit button

59 views
Skip to first unread message

Atul Grover

unread,
Jun 12, 2021, 3:54:54 PM6/12/21
to TiddlyWiki
Hi all,

I am trying to add a shortcut... I don't know what the first line of the code should be... Please help.

<$list filter="[[ $:/core/ui/Buttons/edit ]is[missing]] [{ $:/core/ui/Buttons/edit  }removeprefix[show]]" emptyMessage="""
<$action-setfield $tiddler="$:/config/ViewToolbarButtons/Visibility/$:/core/ui/Buttons/edit" text="show"/>
""">
<$action-setfield $tiddler="$:/config/ViewToolbarButtons/Visibility/$:/core/ui/Buttons/edit" text="hide"/>
</$list>

Regards AG

Eric Shulman

unread,
Jun 12, 2021, 5:50:15 PM6/12/21
to TiddlyWiki
On Saturday, June 12, 2021 at 12:54:54 PM UTC-7 atulg...@gmail.com wrote:
I am trying to add a shortcut... I don't know what the first line of the code should be... Please help.

Try this: 
<$list filter="[[$:/config/ViewToolbarButtons/Visibility/$:/core/ui/Buttons/edit]get[text]!match[show]]" emptyMessage="""
   <$action-setfield $tiddler="$:/config/ViewToolbarButtons/Visibility/$:/core/ui/Buttons/edit" text="hide"/>""">
   <$action-setfield $tiddler="$:/config/ViewToolbarButtons/Visibility/$:/core/ui/Buttons/edit" text="show"/>
</$list> 

Notes:
* if the config tiddler does not exist or has content matching "show", then the "hide" action is performed
* otherwise the "show" action is performed

Also, you can make the code more compact, by defining the config tiddler title using a macro
and using a filtered transclusion instead of a $list widget to set the content to show or hide, like this:
\define config() $:/config/ViewToolbarButtons/Visibility/$:/core/ui/Buttons/edit
<$action-setfield $tiddler=<<config>> text={{{ [<config>get[text]!match[show]then[show]else[hide]] }}}/>

enjoy,
-e

Eric Shulman

unread,
Jun 12, 2021, 5:53:55 PM6/12/21
to TiddlyWiki
addendum:

When used as a shortcut, I'm not sure that the macro definition for the config tiddler title will be available.
If this is the case, then you can also write it this way:
<$vars config="$:/config/ViewToolbarButtons/Visibility/$:/core/ui/Buttons/edit">
<$action-setfield $tiddler=<<config>> text={{{ [<config>get[text]!match[show]then[show]else[hide]] }}}/>
</$vars>

-e

Atul Grover

unread,
Jun 13, 2021, 1:04:41 AM6/13/21
to TiddlyWiki
Thanks Eric.... Works beautifully... YOU ARE THE MAN!
Reply all
Reply to author
Forward
0 new messages