1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-23 10:07:19 +00:00

Add new tm-focus-selector message

This commit is contained in:
Jeremy Ruston 2019-06-28 17:27:36 +01:00
parent 274dffe750
commit ed67f4a88b
2 changed files with 25 additions and 0 deletions

View File

@ -34,6 +34,19 @@ exports.startup = function() {
$tw.rootWidget.addEventListener("tm-copy-to-clipboard",function(event) {
$tw.utils.copyToClipboard(event.param);
});
// Install the tm-focus-selector message
$tw.rootWidget.addEventListener("tm-focus-selector",function(event) {
var selector = event.param || "",
element;
try {
element = document.querySelector(selector);
} catch(e) {
console.log("Error in selector: ",selector)
}
if(element && element.focus) {
element.focus();
}
});
// Install the scroller
$tw.pageScroller = new $tw.utils.PageScroller();
$tw.rootWidget.addEventListener("tm-scroll",function(event) {

View File

@ -0,0 +1,12 @@
caption: tm-focus-selector
created: 20190628162542132
modified: 20190628162542132
tags: Messages
title: WidgetMessage: tm-focus-selector
type: text/vnd.tiddlywiki
The `tm-focus-selector` message sets the focus to the DOM element identified by the selector in the `param` parameter.
|!Name |!Description |
|param |Selector identifying the DOM element to be focussed |