help needed with action code to be used for a shortcut

52 views
Skip to first unread message

Harris

unread,
Oct 6, 2019, 7:07:54 AM10/6/19
to TiddlyWiki
Dear TW community,

I have created a new shortcut tiddler.
$:/config/ShortcutInfo/test
I have added the shortcut Alt-S for all platforms in the keyboard shortcuts tab of $:/ControlPanel

I need a global keyboard shortcut so I have also added $:/tags/KeyboardShortcut to the tag field $:/config/ShortcutInfo/test

In order to use the Keyboard Shortcut Descriptor:
in $:/config/ShortcutInfo/test I have added a field named "key" with value "Alt-S"

I am now trying to define the action and would need some help in terms of what to add in the textarea of $:/config/ShortcutInfo/test. I need the action to be: save the whole wiki; (as opposed to saving a tiddler that is being edited).

Please excuse my ignorance. Any help with the code would be appreciated.

I have tried to search inside a blank TW to find the code for the action and reuse it but got lost.

(To put the need for this shortcut in context, I have disabled autosave so I want to be saving manually periodically using a keyboard shortcut.)

Many thanks 
Harris

P.s. 
I have referred to the instructions here:


Later I also found this thread which was helpful but I still need help with the action code:

TonyM

unread,
Oct 6, 2019, 8:57:50 AM10/6/19
to TiddlyWiki
A quick clue. Full answer later. Find the save button with advanced search and find out how it does it.

Fishing lesson

Tony

Harris

unread,
Oct 6, 2019, 4:36:26 PM10/6/19
to TiddlyWiki
Hi Tony,
Thanks for the clue. I had partially done such a search prior to posting but gave up in the end.

I had found $:/core/images/save-button but then got stuck and could not find the callback linked to this button.

I had also found but they didn't seem to give me the code for the action:
  • $:/core/save/all
  • $:/core/modules/commands/save.js
  • $:/core/modules/commands/savetiddlers.js

I will do another search. 

Thanks again.
Harris

Harris

unread,
Oct 6, 2019, 4:55:01 PM10/6/19
to TiddlyWiki
Tony, your clue reassured me that I am in the right direction. I searched again and found $:/core/ui/Buttons/save-wiki
It was listed under shadow tiddlers. In my last attempt I had only searched under "core" and "filter" in advanced search.

I extracted the relevant code from $:/core/ui/Buttons/save-wiki and it works like a charm! :-)

Thanks again 
Harris

P.s.1 Embarrassed to say that I spent ~3 hours on the whole thing earlier today but in the 2nd attempt just now the solution came up very quickly. I think I was a bit muddled earlier today and not fully alert.

p.s.2 code below in case it is useful to anybody else:

<$navigator story="$:/StoryList" >
<$action-sendmessage $message="tm-save-wiki" $param={{$:/config/SaveWikiButton/Template}} filename=<<site-title>>/>
</$navigator>  

TonyM

unread,
Oct 6, 2019, 7:02:04 PM10/6/19
to TiddlyWiki
Harris,

Great to hear. I assure you that investment in time will be empowering you to solve future problems, however do not hesitate to ask again in the forum, when baffled. The key thing I wanted you to find was $message="tm-save-wiki", because I could not be sure I new the message name correctly. With this you are empowered to make your own action that calls the core action to save wiki.

Regards
Tony
Reply all
Reply to author
Forward
0 new messages