From 3705bf0531f955acd23a0d173423a88bd7c9db0e Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Sat, 2 Jun 2018 22:24:31 +0300 Subject: [PATCH] added path support to keyboard actions... Signed-off-by: Alex A. Naanou --- ui (gen4)/lib/keyboard.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/ui (gen4)/lib/keyboard.js b/ui (gen4)/lib/keyboard.js index c7cec1b7..ffa8211d 100755 --- a/ui (gen4)/lib/keyboard.js +++ b/ui (gen4)/lib/keyboard.js @@ -1193,11 +1193,10 @@ function makeKeyboardHandler(keyboard, unhandled, actions){ // action call syntax... // XXX should this be a Keyboard thing or a context thing??? } else if(actions.parseStringHandler || kb.parseStringHandler){ - //} else if(kb.parseStringHandler){ var h = (actions.parseStringHandler || kb.parseStringHandler)(handler, actions) - //var h = kb.parseStringHandler(handler) + var path = h ? h.action.split('.') : [] - if(h && h.action in actions){ + if(path.length > 0 && path[0] in actions){ did_handling = true evt @@ -1205,7 +1204,13 @@ function makeKeyboardHandler(keyboard, unhandled, actions){ && evt.preventDefault() // call the handler... - res = actions[h.action].apply(actions, h.arguments) + var context = actions + res = path + .reduce(function(res, k){ + context = res + return res[k] + }, actions) + .apply(context, h.arguments) evt && h.stop_propagation