diff options
| author | Stephen Blott | 2015-06-05 07:27:51 +0100 |
|---|---|---|
| committer | Stephen Blott | 2015-06-05 07:27:51 +0100 |
| commit | fc4cfc478346c2b2769420d47ae00bdbc756a02a (patch) | |
| tree | 916fd51f4cb40991786917e54fb79467d273d0d6 /content_scripts/mode.coffee | |
| parent | b5f4f1ab1f237795ed522f338dde2aa87bb35f42 (diff) | |
| parent | 83fc0e58f6139ff5a1ae37fc300ea647da079171 (diff) | |
| download | vimium-fc4cfc478346c2b2769420d47ae00bdbc756a02a.tar.bz2 | |
Merge pull request #1716 from smblott-github/global-marks
Improved global marks
Diffstat (limited to 'content_scripts/mode.coffee')
| -rw-r--r-- | content_scripts/mode.coffee | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/content_scripts/mode.coffee b/content_scripts/mode.coffee index f631b4cd..ffabc111 100644 --- a/content_scripts/mode.coffee +++ b/content_scripts/mode.coffee @@ -47,6 +47,13 @@ class Mode @id = "#{@name}-#{@count}" @log "activate:", @id + # If options.suppressAllKeyboardEvents is truthy, then all keyboard events are suppressed. This avoids + # 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" ] + @options[type] = @alwaysSuppressEvent @options[type] + @push keydown: @options.keydown || null keypress: @options.keypress || null @@ -171,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: -> |
