mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-06-28 16:23:15 +00:00
Add new tm-focus-selector message
This commit is contained in:
parent
274dffe750
commit
ed67f4a88b
|
@ -34,6 +34,19 @@ exports.startup = function() {
|
||||||
$tw.rootWidget.addEventListener("tm-copy-to-clipboard",function(event) {
|
$tw.rootWidget.addEventListener("tm-copy-to-clipboard",function(event) {
|
||||||
$tw.utils.copyToClipboard(event.param);
|
$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
|
// Install the scroller
|
||||||
$tw.pageScroller = new $tw.utils.PageScroller();
|
$tw.pageScroller = new $tw.utils.PageScroller();
|
||||||
$tw.rootWidget.addEventListener("tm-scroll",function(event) {
|
$tw.rootWidget.addEventListener("tm-scroll",function(event) {
|
||||||
|
|
|
@ -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 |
|
||||||
|
|
Loading…
Reference in New Issue
Block a user