How to create a shortcut for a user-created button?

Greetings TW Community

I am trying to create a keyboard shortcut for a button that I’ve just created:

<$button class="tc-btn-invisible">{{plus.png}}
<$action-sendmessage $message="tm-new-tiddler"
   title="Test Tiddler"
   Concerns =""
/>

</$button>

I followed the instructions as per the tiddlywiki documentation:

  1. Created $:/config/ShortcutInfo/new-math-tiddler
  2. Defined the shortcut key to be shift-alt-n from the control panel
  3. Create keyboard shortcut tiddler

However at step three I didn’t know what to put into the “actions in its text field” part. I tried to figure it out by looking at $:/core/ui/KeyboardShortcuts/new-tiddler but I honestly don’t understand what any of it is saying. Can someone please help? Thanks

If you place the actions you currently have in your button in a macro or procedure (eg your-actions) with the global tag, both your button can use actions=<<your-actions>> and the sortcut can be given the same actions.

  • Although I am not good at making sortcuts, this part is what I understand.

I’m sorry I still don’t know how to do any of these things yet. :sweat_smile:

1 Like

I would have to learn myself, lets see if somepone else can help. Otherways I will help if you are stuck too long.

1 Like

All right. Thank you.

Have a closer look at this howto: https://tiddlywiki.com/#How%20to%20create%20dynamic%20editor%20toolbar%20buttons

It’s interactive and should give you the needed info

For step 3 (create a global keyboard shortcut actions tiddler), do this:

  • Create a tiddler (e.g., “NewMathActions”)
  • Add a tag of $:/tags/KeyboardShortcut
  • Add a field named “key” containing: ((new-math-tiddler))
  • In the text body of the tiddler, enter:
<$navigator
   story="$:/StoryList"
   history="$:/HistoryList"
   openLinkFromInsideRiver={{$:/config/Navigation/openLinkFromInsideRiver}}
   openLinkFromOutsideRiver={{$:/config/Navigation/openLinkFromOutsideRiver}}
   relinkOnRename={{$:/config/RelinkOnRename}}>
<$action-sendmessage $message="tm-new-tiddler"
   title="Test Tiddler" Concerns=""
/>
</$navigator>

You can then use shift-alt-N to trigger the tm-new-tiddler message with the specified fields (title and Concerns).

enjoy,
-e

1 Like

Thanks @EricShulman.

I need your help on a related problem:

The default title of the shortcut ‘new-math-tiddler’ is New Math Tiddler. Let’s say a tiddler with the title New Math Tiddler exists. If I create a ‘new-math-tiddler’ it would overwrite the existing New Math Tiddler (see images below). How would I make it behave in such a way that it would not overwrite the existing tiddler and instead create a new tiddler with a number appended on it just like it would on a default tiddlywiki new-tiddler shortcut/button?




In your NewMathActions tiddler, replace this:

<$action-sendmessage $message="tm-new-tiddler" title="New Math Tiddler" Concerns="" />

with:

<$action-createtiddler $basetitle="New Math Tiddler" Concerns="">
<$action-sendmessage $message="tm-edit-tiddler" $param=<<createTiddler-title>>/>
</$action-createtiddler>

enjoy,
-e

refs:
https://tiddlywiki.com/#ActionCreateTiddlerWidget
https://tiddlywiki.com/#WidgetMessage%3A%20tm-edit-tiddler

I now that this is how it works; I’ve stumbled across this several times. But I’m curious as to whether there’s a technical reason that the tm-new-tiddler couldn’t get a $basetitle as well, so that it could use the same mechanism as action-createtiddler? It seems like an obvious thing to want.