mirror of
				https://github.com/Jermolene/TiddlyWiki5
				synced 2025-10-30 23:23:02 +00:00 
			
		
		
		
	Keyboard widget: don't refresh when class changes (#5758)
This commit is contained in:
		| @@ -40,9 +40,8 @@ KeyboardWidget.prototype.render = function(parent,nextSibling) { | |||||||
| 	// Create element | 	// Create element | ||||||
| 	var domNode = this.document.createElement(tag); | 	var domNode = this.document.createElement(tag); | ||||||
| 	// Assign classes | 	// Assign classes | ||||||
| 	var classes = (this["class"] || "").split(" "); | 	this.domNode = domNode; | ||||||
| 	classes.push("tc-keyboard"); | 	this.assignDomNodeClasses(); | ||||||
| 	domNode.className = classes.join(" "); |  | ||||||
| 	// Add a keyboard event handler | 	// Add a keyboard event handler | ||||||
| 	$tw.utils.addEventListeners(domNode,[ | 	$tw.utils.addEventListeners(domNode,[ | ||||||
| 		{name: "keydown", handlerObject: this, handlerMethod: "handleChangeEvent"} | 		{name: "keydown", handlerObject: this, handlerMethod: "handleChangeEvent"} | ||||||
| @@ -90,7 +89,6 @@ KeyboardWidget.prototype.execute = function() { | |||||||
| 	this.key = this.getAttribute("key",""); | 	this.key = this.getAttribute("key",""); | ||||||
| 	this.tag = this.getAttribute("tag",""); | 	this.tag = this.getAttribute("tag",""); | ||||||
| 	this.keyInfoArray = $tw.keyboardManager.parseKeyDescriptors(this.key); | 	this.keyInfoArray = $tw.keyboardManager.parseKeyDescriptors(this.key); | ||||||
| 	this["class"] = this.getAttribute("class",""); |  | ||||||
| 	if(this.key.substr(0,2) === "((" && this.key.substr(-2,2) === "))") { | 	if(this.key.substr(0,2) === "((" && this.key.substr(-2,2) === "))") { | ||||||
| 		this.shortcutTiddlers = []; | 		this.shortcutTiddlers = []; | ||||||
| 		var name = this.key.substring(2,this.key.length -2); | 		var name = this.key.substring(2,this.key.length -2); | ||||||
| @@ -102,14 +100,22 @@ KeyboardWidget.prototype.execute = function() { | |||||||
| 	this.makeChildWidgets(); | 	this.makeChildWidgets(); | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  | KeyboardWidget.prototype.assignDomNodeClasses = function() { | ||||||
|  | 	var classes = this.getAttribute("class","").split(" "); | ||||||
|  | 	classes.push("tc-keyboard"); | ||||||
|  | 	this.domNode.className = classes.join(" "); | ||||||
|  | }; | ||||||
|  |  | ||||||
| /* | /* | ||||||
| Selectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering | Selectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering | ||||||
| */ | */ | ||||||
| KeyboardWidget.prototype.refresh = function(changedTiddlers) { | KeyboardWidget.prototype.refresh = function(changedTiddlers) { | ||||||
| 	var changedAttributes = this.computeAttributes(); | 	var changedAttributes = this.computeAttributes(); | ||||||
| 	if(changedAttributes.message || changedAttributes.param || changedAttributes.key || changedAttributes["class"] || changedAttributes.tag) { | 	if(changedAttributes.message || changedAttributes.param || changedAttributes.key || changedAttributes.tag) { | ||||||
| 		this.refreshSelf(); | 		this.refreshSelf(); | ||||||
| 		return true; | 		return true; | ||||||
|  | 	} else if(changedAttributes["class"]) { | ||||||
|  | 		this.assignDomNodeClasses(); | ||||||
| 	} | 	} | ||||||
| 	// Update the keyInfoArray if one of its shortcut-config-tiddlers has changed | 	// Update the keyInfoArray if one of its shortcut-config-tiddlers has changed | ||||||
| 	if(this.shortcutTiddlers && $tw.utils.hopArray(changedTiddlers,this.shortcutTiddlers)) { | 	if(this.shortcutTiddlers && $tw.utils.hopArray(changedTiddlers,this.shortcutTiddlers)) { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Simon Huber
					Simon Huber