added path support to keyboard actions...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2018-06-02 22:24:31 +03:00
parent c46b7121d2
commit 3705bf0531

View File

@ -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