fix keyboard handler
This commit is contained in:
parent
b665bb54d1
commit
1d0f0a08c1
1 changed files with 9 additions and 6 deletions
|
@ -75,7 +75,7 @@
|
|||
}
|
||||
|
||||
function onKeydown(e) {
|
||||
var $element = Ox.Focus.focusedElement() || Ox.$body,
|
||||
var $element = Ox.Focus.focusedElement(),
|
||||
isInput = Ox.Focus.focusedElementIsInput(),
|
||||
keyName = Ox.KEYS[e.keyCode],
|
||||
keyBasename = keyName.split('.')[0],
|
||||
|
@ -86,11 +86,11 @@
|
|||
}).concat(keyName).join('_'),
|
||||
event = 'key.' + key,
|
||||
triggerEvent = function() {
|
||||
if (Ox.Focus.focusedElement()) {
|
||||
if ($element) {
|
||||
$element.triggerEvent.apply($element, arguments);
|
||||
} else if (!isInput) {
|
||||
Ox.Event.trigger.apply(
|
||||
$element, [{}].concat(Ox.slice(arguments))
|
||||
Ox.$body, [{}].concat(Ox.slice(arguments))
|
||||
);
|
||||
}
|
||||
};
|
||||
|
@ -114,9 +114,12 @@
|
|||
resetTimeout = setTimeout(function() {
|
||||
keys = '';
|
||||
}, 1000);
|
||||
if (
|
||||
Ox.contains(keyboardCallbacks[$element.oxid || 0] || [], event)
|
||||
) {
|
||||
if (Ox.contains(keyboardCallbacks[0], event) || (
|
||||
$element && keyboardCallbacks[$element.oxid]
|
||||
&& Ox.contains(keyboardCallbacks[$element.oxid], event)
|
||||
)) {
|
||||
// if there is a global handler for this keyboard event, or a
|
||||
// handler on the focused element, then prevent default
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue