Limiting the scope of global keyboard shortcuts

50 views
Skip to first unread message

Hubert

unread,
Feb 12, 2019, 10:04:05 AM2/12/19
to TiddlyWiki
Hello,

How can I limit the scope of a global keyboard shortcut?

I have the below code to navigate to my Startpage on pressing alt+h. This key combination works across the whole TW. However, I'd like to limit the scope where the action is triggered to a condition where a tiddler named X is in the top of the story river (so, make the key combination trigger this action only when tiddler X is open and/or top of story river).

The code:

<$navigator story="$:/StoryList" history="$:/HistoryList">
<$action-sendmessage $message="tm-close-other-tiddlers" $param="Startpage"/>
<$action-navigate $to="Startpage"/>
</$navigator>

The reason I'm asking is that I want to re-use the same key combinations across specific tiddlers to trigger different actions depending on a tiddler that's currently open/top of story river.

Many thanks!

Best,
Hubert

BurningTreeC

unread,
Feb 12, 2019, 10:55:35 AM2/12/19
to TiddlyWiki
Hi Hubert,

you can do this like this:

<$navigator story="$:/StoryList" history="$:/HistoryList">
<$action-sendmessage $message="tm-close-other-tiddlers" $param={{{ [list[$:/StoryList]first[]] }}}/>
<$action-navigate $to={{{ [list[$:/StoryList]first[]] }}}/>
</$navigator>


Hubert

unread,
Feb 12, 2019, 11:12:19 AM2/12/19
to TiddlyWiki
Thanks again for your help and apologies for my awkward phrasing.

I can see that this code still works across the whole TW. What it does is navigate to the tiddler on the top of the story river (the action), but the scope of this action is still global, i.e. the key combination will trigger the navigate action no matter what tiddler is currently top of the story river.

What I'm trying to achieve instead is trigger some action (doesn't really matter what action) by the assigned key combination ONLY IF a specified tiddler, say HelloThere, is currently top of the story river.

In short: I hit alt+h and nothing happens UNLESS HelloThere is currently opened. I'd add actions afterwards, what I'm trying to define is the scope for the action.

Is this possible?

Thanks again for your help and patience :)

Regards,
Hubert

BurningTreeC

unread,
Feb 12, 2019, 11:29:39 AM2/12/19
to TiddlyWiki
Thanks again for your help and apologies for my awkward phrasing.

I can see that this code still works across the whole TW. What it does is navigate to the tiddler on the top of the story river (the action), but the scope of this action is still global, i.e. the key combination will trigger the navigate action no matter what tiddler is currently top of the story river.

What I'm trying to achieve instead is trigger some action (doesn't really matter what action) by the assigned key combination ONLY IF a specified tiddler, say HelloThere, is currently top of the story river.

In short: I hit alt+h and nothing happens UNLESS HelloThere is currently opened. I'd add actions afterwards, what I'm trying to define is the scope for the action.

Is this possible?

yes, you do this by filtering:

<$navigator story="$:/StoryList" history="$:/HistoryList">
<$list filter="[list[$:/StoryList]first[]removeprefix[HelloThere]suffix[]]">
<$action-sendmessage $message="tm-close-other-tiddlers" $param={{{ 
[list[$:/StoryList]first[]] }}}/>
<$action-navigate $to={{{ [list[$:/StoryList]first[]] }}}/>
</$list>
</$navigator>

removeprefix[HelloThere] makes sure that the tiddler title starts with "HelloThere" (replace it with your tiddler-title)
suffix[] makes sure that it's not HelloThere...ere...ere (...)


Hubert

unread,
Feb 12, 2019, 12:22:57 PM2/12/19
to TiddlyWiki
Thank you!! It works perfectly. Thanks again for your time.

Best regards,
Hubert
Reply all
Reply to author
Forward
0 new messages