diff options
| author | Stephen Blott | 2015-01-09 17:38:57 +0000 |
|---|---|---|
| committer | Stephen Blott | 2015-01-09 17:48:22 +0000 |
| commit | 8e65f74eea14850794ded12a0039a80e825ffa8d (patch) | |
| tree | e9d2ff722d0a9d88e3d54eab8dec6cf2d2faa5b2 | |
| parent | dc423eff18b2b2654c175633cd11e28ea9279fd7 (diff) | |
| download | vimium-8e65f74eea14850794ded12a0039a80e825ffa8d.tar.bz2 | |
Modes; handle normal mode return values.
Up until this point in the development of modes, we've just let the
normal mode handlers return whatever they previously would have
returned. This allowed keyboard events to continue bubbling down the
stack, but didn't matter, because normal mode is the last keyboard
handler on the stack.
This changes that. Now, normal-mode key handlers return the right value
to have the handler stack stop or continue bubbling, as appropriate.
| -rw-r--r-- | content_scripts/vimium_frontend.coffee | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index d91bb181..97fbc56f 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -465,17 +465,20 @@ onKeypress = (event, extra) -> # Enter insert mode when the user enables the native find interface. if (keyChar == "f" && KeyboardUtils.isPrimaryModifierKey(event)) enterInsertModeWithoutShowingIndicator() - return true + return handlerStack.stopBubblingAndTrue if (keyChar) if (findMode) handleKeyCharForFindMode(keyChar) DomUtils.suppressEvent(event) + return handlerStack.stopBubblingAndTrue else if (!isInsertMode() && !findMode) if (isPassKey keyChar) return handlerStack.stopBubblingAndTrue if currentCompletionKeys.indexOf(keyChar) != -1 or isValidFirstKey(keyChar) DomUtils.suppressEvent(event) + keyPort.postMessage({ keyChar:keyChar, frameId:frameId }) + return handlerStack.stopBubblingAndTrue keyPort.postMessage({ keyChar:keyChar, frameId:frameId }) @@ -520,37 +523,45 @@ onKeydown = (event, extra) -> exitInsertMode() DomUtils.suppressEvent event KeydownEvents.push event + return handlerStack.stopBubblingAndTrue else if (findMode) if (KeyboardUtils.isEscape(event)) handleEscapeForFindMode() DomUtils.suppressEvent event KeydownEvents.push event + return handlerStack.stopBubblingAndTrue else if (event.keyCode == keyCodes.backspace || event.keyCode == keyCodes.deleteKey) handleDeleteForFindMode() DomUtils.suppressEvent event KeydownEvents.push event + return handlerStack.stopBubblingAndTrue else if (event.keyCode == keyCodes.enter) handleEnterForFindMode() DomUtils.suppressEvent event KeydownEvents.push event + return handlerStack.stopBubblingAndTrue else if (!modifiers) DomUtils.suppressPropagation(event) KeydownEvents.push event + return handlerStack.stopBubblingAndTrue else if (isShowingHelpDialog && KeyboardUtils.isEscape(event)) hideHelpDialog() DomUtils.suppressEvent event KeydownEvents.push event + return handlerStack.stopBubblingAndTrue else if (!isInsertMode() && !findMode) if (keyChar) if (currentCompletionKeys.indexOf(keyChar) != -1 or isValidFirstKey(keyChar)) DomUtils.suppressEvent event KeydownEvents.push event + keyPort.postMessage({ keyChar:keyChar, frameId:frameId }) + return handlerStack.stopBubblingAndTrue keyPort.postMessage({ keyChar:keyChar, frameId:frameId }) @@ -572,12 +583,14 @@ onKeydown = (event, extra) -> isValidFirstKey(KeyboardUtils.getKeyChar(event)))) DomUtils.suppressPropagation(event) KeydownEvents.push event + return handlerStack.stopBubblingAndTrue return true onKeyup = (event) -> - DomUtils.suppressPropagation(event) if KeydownEvents.pop event - return true + return true unless KeydownEvents.pop event + DomUtils.suppressPropagation(event) + handlerStack.stopBubblingAndTrue checkIfEnabledForUrl = -> url = window.location.toString() |
