How set focus?

38 views
Skip to first unread message

Mat

unread,
Jul 21, 2019, 7:57:48 PM7/21/19
to TiddlyWikiDev
The docs for widgetmessage tm-focus-selector reads


The tm-focus-selector message sets the focus to the DOM element identified by the selector in the param parameter.

NameDescription
paramSelector identifying the DOM element to be focussed

how do I know what DOM element it is? And exactly how to I give this as an argument ( param="????" )

Is it possible to use an ID attribute for this? If "no", would it make sense to propose this as an option for the widgetmessage? (I would think more people can create CSS IDs than manage DOM elements.)

What I'm trying to achieve is setting focus on a edit-text field after I've set another thing.

<:-)

Simon Huber

unread,
Jul 22, 2019, 2:05:33 AM7/22/19
to TiddlyWikiDev
Hi Mat,

look at the Advanced search Keyboard Shortcut in the current prerelease, it uses the tm-focus-selector message by using a [data-tiddler-title="..."] selector,

It should work the same way using an id

Simon Huber

unread,
Jul 22, 2019, 2:07:10 AM7/22/19
to TiddlyWikiDev
The best way to use it would probably be giving the input a unique class

Mat

unread,
Jul 22, 2019, 8:16:57 AM7/22/19
to TiddlyWikiDev
Ah, timely introduced in 5.1.20! Maybe even thanks to you? :-)

Unfortunately I don't think I'll be able to use it for lack of enclosing characters. The idea is to set focus on a field in the edit view but 

<$linkcatcher actions=""" ...
<$action-sendmessage $message="tm-focus-selector"
   $param="[data-tiddler-title="Draft of 'aaa'"] ... "
/> """>

...i.e outer enclosure is """ , and because the target is a Draft tiddler, the single quote (') is already taken... so this means there is only single double quote (") left for both of the $param and the data-tiddler-title attribute. The data-tiddler-title even needs enclosure for e.g {{!!title}}, i.e data-tiddler-title="{{!!title}}".

In my attempts I discovered drafts have a !!draft.title field. But apparently this has the same value as !!title, i.e the title of the not-draft. Is this really correct? I can understand why !!draft.of has the name of the original tiddler but not why !!draft.title would have it. (Is it a bug?)

Anybody has any ideas?

<:-)
Reply all
Reply to author
Forward
0 new messages