1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-09-21 03:39:43 +00:00

Keyboard widget should not crash if the keyboard manager has not been initialised

A user reported a problem with using the keyboard widget within a startup action.
This commit is contained in:
Jeremy Ruston 2024-08-29 17:25:30 +01:00
parent 6b13614a6a
commit 7dfdbae812

View File

@ -96,6 +96,7 @@ KeyboardWidget.prototype.execute = function() {
this.param = this.getAttribute("param","");
this.key = this.getAttribute("key","");
this.tag = this.getAttribute("tag","");
if($tw.keyboardManager) {
this.keyInfoArray = $tw.keyboardManager.parseKeyDescriptors(this.key);
if(this.key.substr(0,2) === "((" && this.key.substr(-2,2) === "))") {
this.shortcutTiddlers = [];
@ -104,6 +105,7 @@ KeyboardWidget.prototype.execute = function() {
self.shortcutTiddlers.push("$:/config/" + platformDescriptor + "/" + name);
});
}
}
// Make child widgets
this.makeChildWidgets();
};
@ -126,7 +128,7 @@ KeyboardWidget.prototype.refresh = function(changedTiddlers) {
this.assignDomNodeClasses();
}
// 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) && $tw.keyboardManager) {
this.keyInfoArray = $tw.keyboardManager.parseKeyDescriptors(this.key);
}
return this.refreshChildren(changedTiddlers);