1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-30 13:29:56 +00:00

Keyboard Widget: refresh keyInfoArray (#3541)

this makes a keyboard widget update its keyInfoArray if its key has the `((descriptor))` format and one of the platform-specific configuration tiddlers with that descriptor-suffix changes
This commit is contained in:
BurningTreeC 2018-11-15 17:50:23 +01:00 committed by Jeremy Ruston
parent 4f7297645d
commit 43c8a0f485

View File

@ -79,6 +79,13 @@ KeyboardWidget.prototype.execute = function() {
this.tag = this.getAttribute("tag");
this.keyInfoArray = $tw.keyboardManager.parseKeyDescriptors(this.key);
this["class"] = this.getAttribute("class");
if(this.key.substr(0,2) === "((" && this.key.substr(-2,2) === "))") {
this.shortcutTiddlers = [];
var name = this.key.substring(2,this.key.length -2);
$tw.utils.each($tw.keyboardManager.lookupNames,function(platformDescriptor) {
self.shortcutTiddlers.push("$:/config/" + platformDescriptor + "/" + name);
});
}
// Make child widgets
this.makeChildWidgets();
};
@ -92,6 +99,10 @@ KeyboardWidget.prototype.refresh = function(changedTiddlers) {
this.refreshSelf();
return true;
}
// Update the keyInfoArray if one of its shortcut-config-tiddlers has changed
if(this.shortcutTiddlers && $tw.utils.hopArray(changedTiddlers,this.shortcutTiddlers)) {
this.keyInfoArray = $tw.keyboardManager.parseKeyDescriptors(this.key);
}
return this.refreshChildren(changedTiddlers);
};