mirror of
				https://github.com/Jermolene/TiddlyWiki5
				synced 2025-11-04 01:23:01 +00:00 
			
		
		
		
	Add new tm-focus-selector message
This commit is contained in:
		@@ -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) {
 | 
			
		||||
 
 | 
			
		||||
@@ -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  |
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user