1
0
Fork 0

canvas.Keybinding.parseShortcut: Accept nil and empty strings, returning nil

This can be used to unset the key binding of a Canvas menu item by using item.setShortcut(nil);
This commit is contained in:
TheFGFSEagle 2023-10-06 20:17:25 +02:00
parent 10306ea92d
commit 5f66773605

View file

@ -283,7 +283,7 @@ ModifierKeys.Meta = (ModifierKeys.Meta_L | ModifierKeys.Meta_R);
var parseShortcut = func(s)
{
if (size(s) == 0) {
if (!s or !isstr(s) or size(s) == 0) {
return nil;
}
@ -315,6 +315,7 @@ var parseShortcut = func(s)
if (keyCode == nil) {
logprint(LOG_ALERT, "Unknown key '" ~ baseKey ~ "'");
return nil;
}
return [modMask, keyCode];