mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-10 20:09:57 +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:
parent
6b13614a6a
commit
7dfdbae812
@ -96,13 +96,15 @@ KeyboardWidget.prototype.execute = function() {
|
|||||||
this.param = this.getAttribute("param","");
|
this.param = this.getAttribute("param","");
|
||||||
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);
|
if($tw.keyboardManager) {
|
||||||
if(this.key.substr(0,2) === "((" && this.key.substr(-2,2) === "))") {
|
this.keyInfoArray = $tw.keyboardManager.parseKeyDescriptors(this.key);
|
||||||
this.shortcutTiddlers = [];
|
if(this.key.substr(0,2) === "((" && this.key.substr(-2,2) === "))") {
|
||||||
var name = this.key.substring(2,this.key.length -2);
|
this.shortcutTiddlers = [];
|
||||||
$tw.utils.each($tw.keyboardManager.lookupNames,function(platformDescriptor) {
|
var name = this.key.substring(2,this.key.length -2);
|
||||||
self.shortcutTiddlers.push("$:/config/" + platformDescriptor + "/" + name);
|
$tw.utils.each($tw.keyboardManager.lookupNames,function(platformDescriptor) {
|
||||||
});
|
self.shortcutTiddlers.push("$:/config/" + platformDescriptor + "/" + name);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Make child widgets
|
// Make child widgets
|
||||||
this.makeChildWidgets();
|
this.makeChildWidgets();
|
||||||
@ -126,7 +128,7 @@ KeyboardWidget.prototype.refresh = function(changedTiddlers) {
|
|||||||
this.assignDomNodeClasses();
|
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) && $tw.keyboardManager) {
|
||||||
this.keyInfoArray = $tw.keyboardManager.parseKeyDescriptors(this.key);
|
this.keyInfoArray = $tw.keyboardManager.parseKeyDescriptors(this.key);
|
||||||
}
|
}
|
||||||
return this.refreshChildren(changedTiddlers);
|
return this.refreshChildren(changedTiddlers);
|
||||||
|
Loading…
Reference in New Issue
Block a user