i trying set hotkeys in ext.js project. code below.
_sethotkeys: function(values, button){ var hotkeymap = { target: document, binding:[] }; for(var = 0; < values.length; i++){ if(values[i].hotkey){ hotkeymap.binding.push({ key: values[i].hotkey, fn: this._handlefillinvaluebuttontoggle(button, true) }); } } console.log(hotkeymap); var keymap = new ext.util.keymap(hotkeymap); },
i have function, _handlefillinvaluebuttontoggle
called when hot key pressed. result of console.log(hotkeymap)
shows fn
never being set function, instead undefined:
{ target: document, binding: [ { fn: undefined, key: "e"}, { fn: undefined, key: "c"}, { fn: undefined, key: "n"}, { fn: undefined, key: "d"}, ] }
how can call function when hotkey pressed?
instead of calling function directly, call function calls function want, while passing in scope.
hotkeymap.binding.push({ key: values[i].hotkey, fn: function(){ this._handlefillinvaluebuttontoggle(button, true); }, scope: });
Comments
Post a Comment