accessKey for <script>

7 views
Skip to first unread message

RA

unread,
Dec 28, 2007, 12:56:33 PM12/28/07
to TiddlyWiki
How do I assign a hotkey for a script? I found one way but it works
only when the tiddler is open. It does not work when the script is
inside a popup.

<part Bookmarklets hidden>
<script label="home" title="back to home view">
story.closeAllTiddlers();
restart();
refreshPageTemplate();
return false;
</script><script>place.lastChild.accessKey="H";</script>
</part>

Eric Shulman

unread,
Dec 28, 2007, 1:32:11 PM12/28/07
to TiddlyWiki


On Dec 28, 9:56 am, RA <nameany...@gmail.com> wrote:
> How do I assign a hotkey for a script? I found one way but it works
> only when the tiddler is open. It does not work when the script is
> inside a popup.

The technique you used (assigning the place.lastChild.accessKey) is
correct. However, access keys only work for elements that are
currently rendered. Popup contents are rendered "on the fly", so the
access key isn't defined until the popup is visible, and is removed
again when the popup is dismissed.

-e

RA

unread,
Dec 28, 2007, 1:52:32 PM12/28/07
to TiddlyWiki
So what would be the technique to have the script always accessible
via access key?

Eric Shulman

unread,
Dec 28, 2007, 2:05:54 PM12/28/07
to TiddlyWiki
> So what would be the technique to have the script always accessible
> via access key?

make sure it is rendered somewhere that is never removed (like in the
main menu)

also... to make it a bit cleaner to set the access key, I've just
updated (v1.8.0)
http://www.TiddlyTools.com/#InlineJavascriptPlugin

so that you can now simply write:
<script label="home" title="back to home view" key="H">
instead of using
</script><script>place.lastChild.accessKey="H";</script>
following the onclick script.

enjoy,
-e
Reply all
Reply to author
Forward
0 new messages