aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Blott2015-06-05 05:04:56 +0100
committerStephen Blott2015-06-05 05:06:23 +0100
commit50980718d848ca324b6fca0568e2fa7203d51d52 (patch)
treecf98e7ed61df58922064e8b0759690d3b6a844f1
parent89c3ab075994de9b11952784eb5752da445df576 (diff)
downloadvimium-50980718d848ca324b6fca0568e2fa7203d51d52.tar.bz2
Fix event suppression for Marks keyboard events.
-rw-r--r--content_scripts/mode.coffee14
1 files changed, 10 insertions, 4 deletions
diff --git a/content_scripts/mode.coffee b/content_scripts/mode.coffee
index 9105fabb..ffabc111 100644
--- a/content_scripts/mode.coffee
+++ b/content_scripts/mode.coffee
@@ -48,12 +48,11 @@ class Mode
@log "activate:", @id
# If options.suppressAllKeyboardEvents is truthy, then all keyboard events are suppressed. This avoids
- # the need for modes which block all keyboard events 1) to provide handlers for all keyboard events,
- # and 2) to worry about their return values.
+ # the need for modes which suppress all keyboard events 1) to provide handlers for all of those events,
+ # or 2) to worry about event suppression and event-handler return values.
if @options.suppressAllKeyboardEvents
for type in [ "keydown", "keypress", "keyup" ]
- do (handler = @options[type]) =>
- @options[type] = (event) => handler? event; @stopBubblingAndFalse
+ @options[type] = @alwaysSuppressEvent @options[type]
@push
keydown: @options.keydown || null
@@ -179,6 +178,13 @@ class Mode
# case), because they do not need to be concerned with the value they yield.
alwaysContinueBubbling: handlerStack.alwaysContinueBubbling
+ # Shorthand for an event handler which always suppresses event propagation.
+ alwaysSuppressEvent: (handler = null) ->
+ (event) =>
+ handler? event
+ DomUtils.suppressPropagation event
+ @stopBubblingAndFalse
+
# Activate a new instance of this mode, together with all of its original options (except its main
# keybaord-event handlers; these will be recreated).
cloneMode: ->