Keystroke to Close Current Tiddler in TW5

423 views
Skip to first unread message

Kevin Kleinfelter

unread,
Jun 19, 2017, 9:14:38 PM6/19/17
to TiddlyWiki
How would I implement a keystroke to close the current tiddler in TW5?

I have a plugin which does this for TW classic, and I really miss it in TW5.

Tnx

PMario

unread,
Jun 20, 2017, 7:11:45 AM6/20/17
to TiddlyWiki
On Tuesday, June 20, 2017 at 3:14:38 AM UTC+2, Kevin Kleinfelter wrote:
How would I implement a keystroke to close the current tiddler in TW5?

Do you mean while editing? <ctrl><enter>  saves ... <esc> closes edit mode.

-m

Kevin Kleinfelter

unread,
Jun 20, 2017, 7:47:05 AM6/20/17
to TiddlyWiki
While viewing.

PMario

unread,
Jun 20, 2017, 8:12:25 AM6/20/17
to TiddlyWiki
On Tuesday, June 20, 2017 at 1:47:05 PM UTC+2, Kevin Kleinfelter wrote:
While viewing.

TW doesn't know, which tiddler you look at, at the moment. How should we know, what the current tiddler is. ... Which plugin do you use in TWclassic? Do you use a tabbed view?

-m

Mat

unread,
Jun 21, 2017, 5:41:04 PM6/21/17
to TiddlyWiki
Actually, TiddlyMap has a feature that senses which tiddler is in view, called the HotZone plugin. I think it makes this tiddler to be the currentTiddler.

Using this, it should probably be possible to make a close command.

<:-)

Kevin Kleinfelter

unread,
Apr 7, 2018, 3:42:54 PM4/7/18
to TiddlyWiki
Almost a year later, and I'm most of the way to a keystroke to close the current view-mode tiddler.

  • I added tabindex="1" to the div in ViewTemplate.  This makes it possible to select a view-mode tiddler.
  • I wrapped the div with: <$keyboard key="alt-W" message="tm-close-tiddler">
With a story river full of view-mode tiddlers, I can tab among tiddlers and press alt-W to close the selected tiddlers.

When I navigate to a tiddler, I'd like to automatically set focus to it.  I'd like it if clicking on a link to a tiddler not only opened/scrolled to it, it would set focus to that tiddler.  I don't care so much about scrolling, because I typically operate in zoomin mode.  

Now that I've given it a tabindex, is there a way I can set focus to the currently zoomed tiddler when it zooms?

Kevin Kleinfelter

unread,
Apr 7, 2018, 8:49:36 PM4/7/18
to TiddlyWiki
99% of the way there.  In addition to what I said before:
  • I added tabindex="1" to the div in ViewTemplate.  This makes it possible to select a view-mode tiddler.
  • I wrapped the div with: <$keyboard key="alt-W" message="tm-close-tiddler">
I also had to edit $:/config/Search/AutoFocus (shadow tiddler) and set it to: false

I'm still not there.  Focus often winds up on the document body.  (Verified via running some JavaScript in the browser console.)

I need to add an onFocus to the body, which does a setFocus to the first story div.  The only way I know to do that would be to edit $:/core/templates/tiddlywiki5.html .

Can anyone suggest a "tiddlywiki style" way to shift focus from the document body to the first story in the river?

Gabriel Chen

unread,
Jan 22, 2019, 10:14:02 AM1/22/19
to TiddlyWiki
Hi Kevin, 

I was looking for the same solution for a while and found something... emmm, sort of cheating. 
  1. My TiddlyWiki story view is "Zoom In", so there is only one tiddler surfaced at one time;
  2. I noticed the tiddler close button [X] always appears at a fix position (X1415, Y220 on my screen), if the tiddler is short (i.e. no scrolling of the window); 
  3. If the tiddler is long, when [Home] key is pressed, the [X] appears are the same position;
  4. AutoHotKey can be used to send virtual  keystroke and mouse operation (e.g. move the cursor to somewhere and click);
  5. Hence the idea is: once a keystroke (i.e. "Alt + X") is pressed > trigger a piece of AutoHotKey script > Send [Home] key > Move cursor to [X] position > left click
Here is the script, I am using "control + space bar" to fire it: 
; Comment: Use to close tiddler in tiddlywiki
; Comment: Uses [ctrl] + [space] to trigger 
^Space::
SendInput, {Home}
Sleep, 200   ; wait for 0.2s, the page goes up
MouseClick, left, 1415, 220 ;[X] button position in px on the screen
return


revise "^Space" to your preferred key combination: 
  • ; ! = Alt
  • ; ^ = Control
  • ; + = Shift
  • ; # = WindowsKey
  • ; other example: [Ctrl] + [Shift] + [a] = ^+a
Hope it helps. ;-) 

unread,
Aug 31, 2021, 4:04:59 AM8/31/21
to TiddlyWiki
Hi there,

Reviving this thread to point out that https://github.com/MaxGyver83/tw5-keyboard-navigation works really well. The shorcuts are hardcoded but apart from that, it's great. Now only missing the "Close other tiddlers" ("all but FocusTiddler") action!

Best,
Reply all
Reply to author
Forward
0 new messages