Shortcut issue

157 views
Skip to first unread message

Aidan Grey

unread,
Aug 2, 2019, 4:30:13 PM8/2/19
to TiddlyWiki
Hey all,

I created a global shortcut that creates a new tiddler from a template. It works, except that I get this error:

Uncaught TypeError: Cannot read property 'indexOf' of null

I'm expecting to create a ton of tiddlers with the shortcut, so closing the error every time defeats the purpose. What would be the fix for the error?

The action widget is tagged $:/tag/KeyboardShortcut, the key field is "alt+M", and the widget text is:

<$navigator>
<$action-sendmessage 
$message="tm-new-tiddler" 
$param="meaningTemplate"
/>
</$navigator>

What did I miss?

Thanks,
Aidan

PMario

unread,
Aug 3, 2019, 8:18:48 AM8/3/19
to TiddlyWiki
Hi,
Why did you use the navigator widget?
-m

BurningTreeC

unread,
Aug 3, 2019, 8:46:27 AM8/3/19
to TiddlyWiki
Hi Aidan, does it work if you provide a storylist to the navigator widget like

<$navigator story="$:/StoryList">

?

PMario

unread,
Aug 3, 2019, 8:49:37 AM8/3/19
to TiddlyWiki
Hi,

The navigator widget is very heavy weight. ... I think it should be possible to get what you want, without it.

-m

Birthe C

unread,
Aug 3, 2019, 12:27:19 PM8/3/19
to TiddlyWiki
Hi Aidan,

I looked in $:/core/ui/KeyboardShortcuts/new-tiddler, I think you could clone that and make a few changes

That would look like this:
<$navigator story="$:/StoryList" history="$:/HistoryList" openLinkFromInsideRiver={{$:/config/Navigation/openLinkFromInsideRiver}} openLinkFromOutsideRiver={{$:/config/Navigation/openLinkFromOutsideRiver}} relinkOnRename={{$:/config/RelinkOnRename}}>

<$action-sendmessage
    $message="tm-new-tiddler"
    $param="meaningTemplate"
/>
</$navigator>


Birthe

Aidan Grey

unread,
Aug 3, 2019, 12:49:03 PM8/3/19
to TiddlyWiki
Heya Mario,

[[How to create keyboard shortcuts]] says that some actions require to be wrapped within a $navigator widget. That is necessary for the following list of widgets and messages in order to work if used within global keyboard shortcuts, and tm-new-tiddler is in the list.

It didn't do anything at all before I put the <$navigator>  in, which is needed to capture the global shortcuts.

Aidan

--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/158c5a09-32a2-4633-bf4d-e955a4a81d92%40googlegroups.com.

Aidan Grey

unread,
Aug 3, 2019, 12:54:16 PM8/3/19
to TiddlyWiki
Thanks Birthe,

I'll give that a shot and see if I can make it work. 

--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.

Mat

unread,
Aug 3, 2019, 1:10:00 PM8/3/19
to TiddlyWiki
Aidan, actionwidgets typically have to be inside a button. Try this:

<$button>

<$action-sendmessage
 $message="tm-new-tiddler"
 $param="meaningTemplate"
/>
xxx
</$button>

<:-)

Aidan Grey

unread,
Aug 3, 2019, 1:18:13 PM8/3/19
to TiddlyWiki
I specifically DON"T want a button, so I was following the directions for a global shortcut, which don't use buttons. As I noted, it works, but that one weird error.

--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.

Mat

unread,
Aug 3, 2019, 1:37:19 PM8/3/19
to TiddlyWiki
I'm curious; What made you choose specifically the navigator widget as the thing to trigger the action? 

I'm not saying I have any better suggestion, I'm just curious, and actually I'm wondering what things that can trigger actions other than a button and apparently also navigation. Anybody knows?

<:-)

Birthe C

unread,
Aug 3, 2019, 2:02:05 PM8/3/19
to TiddlyWiki
Hi Mat,

When you do not use a button, but want to create a new tiddler from keyboard shortcut, you are not creating the tiddler from inside the story river....at least that is what I am thinking.


Birthe

Aidan Grey

unread,
Aug 3, 2019, 2:05:04 PM8/3/19
to tiddl...@googlegroups.com
What Birthe said, and also because of the previously noted requirement specified in how to create a keyboard shortcut, global section.

--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
Message has been deleted

Mat

unread,
Aug 3, 2019, 2:35:41 PM8/3/19
to TiddlyWiki
(sorry for deleted post. I misunderstood Birthes reply)

Birthe, Aidan, thanks that explains it.

<:-)

Mark S.

unread,
Aug 3, 2019, 3:53:19 PM8/3/19
to TiddlyWiki
I think you do need to wrap it with a minimum of

<$navigator story="$:/StoryList" >
...
</$navigator>

In your original post, you said $:/tag/KeyboardShortcut, but it should be $:/tags/KeyboardShortcut

I'm thinking that the error you're getting suggests something wrong in your template. Perhaps you could share that?

Good luck!

On Saturday, August 3, 2019 at 11:05:04 AM UTC-7, Aidan Grey wrote:
What Birthe said, and also because of the previously noted requirement specified in how to create a keyboard shortcut, global section.

On Sat, Aug 3, 2019, 12:02 PM Birthe C, <strikk...@gmail.com> wrote:
Hi Mat,

When you do not use a button, but want to create a new tiddler from keyboard shortcut, you are not creating the tiddler from inside the story river....at least that is what I am thinking.


Birthe

--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddl...@googlegroups.com.

Aidan Grey

unread,
Aug 3, 2019, 5:09:41 PM8/3/19
to TiddlyWiki
It was the story bit - just tested it, and that fixed it. I did have tagS vs tag, that was just a typo here.


So here's my step by step to create a custom global shortcut, where you don't need a button, or to be in a textarea, or anything. Just hit your shortcut at anytime, and voila. Obviously, your action can be changed easily to whatever you need.


1. Create tiddler named $:/config/ShortcutInfo/<<newShortcut>>
2. Give a description in textarea, if you want
3. Go to Control Panel, then Keyboard Shortcuts 
4. Select your new shortcut name, and give it a unique shortcut (just type the shortcut you want, for example alt+M)
5. Create a new tiddler tagged $:/tags/Keyboard/Shortcut
6. Create a new field "key", which value = your shortcut (e.g. "alt+M")
7. In the textarea, add your action:
<$navigator story="$:/StoryList" > <$action-sendmessage $message="tm-new-tiddler" $param="meaningTemplate" title="This is newly created tiddler" tags="OneTag [[Another Tag]]" text=<<now "Today is DDth, MMM YYYY">> /> </$navigator>  


To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/2117a9f5-9cbe-4f5e-aa7f-22450ee1129e%40googlegroups.com.

TonyM

unread,
Aug 3, 2019, 9:03:48 PM8/3/19
to TiddlyWiki
Aidan,

Thanks for sharing the final solution. This is easy to readapt to using a shortcut to trigger any action or set of actions.

Would it be better to write?

$:/config/ShortcutInfo/newShortcutname

Regards
Tony

Aidan Grey

unread,
Aug 3, 2019, 10:45:34 PM8/3/19
to tiddl...@googlegroups.com
Yes, that's right

To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/138dfb40-c4de-49ab-a759-58930054d761%40googlegroups.com.

Jeremy Ruston

unread,
Aug 4, 2019, 6:43:36 AM8/4/19
to tiddl...@googlegroups.com
Hi Aiden

I created a global shortcut that creates a new tiddler from a template. It works, except that I get this error:

Uncaught TypeError: Cannot read property 'indexOf' of null

I'm expecting to create a ton of tiddlers with the shortcut, so closing the error every time defeats the purpose. What would be the fix for the error?

I’m sorry you ran into problems. It’s worth reiterating a couple of points about the “Red Screen of Embarrassment”:

* The RSOE indicates an uncaught JavaScript error. As such, every time it happens, it qualifies as a bug. Ideally, end users shouldn’t be able to trigger the RSOE unless they are hacking JavaScript

* It’s generally worth reporting RSOEs if you do encounter them. As ever with bug reporting, it’s helpful to have a minimal test case that makes it simple to replicate the problem

* When an RSOE does occur it is strongly recommended that you DO NOT close the message and carry on. There’s a good chance that the JS error might have caused internal corruption. It’s best to dismiss the message, copy any unsaved data via the clipboard, and then refresh the page

In this case, the problem is that the navigator widget does not cope with a missing “story” attribute. I’ve added a fix here:


Best wishes

Jeremy

PMario

unread,
Aug 7, 2019, 2:54:54 AM8/7/19
to TiddlyWiki
Hi,
You are right. ... Global shourtcuts need this construction. ... my bad.
-m
Reply all
Reply to author
Forward
0 new messages