diff options
| author | Stephen Blott | 2015-10-04 09:12:40 +0100 | 
|---|---|---|
| committer | Stephen Blott | 2015-10-04 09:12:40 +0100 | 
| commit | 33d9699a9a5645c5752c6e8c9394101e7b4bbbbe (patch) | |
| tree | 584fa676c522a5468d004c107c294ede150b9029 /content_scripts/mode.coffee | |
| parent | 34452f22ec4c6403deecb59b73d237bcfa7c964a (diff) | |
| download | vimium-33d9699a9a5645c5752c6e8c9394101e7b4bbbbe.tar.bz2 | |
Suppress trailing key events (after link hints).
This ensures that -- on leaving link hints mode -- we consume any trailing keyup events (and don't let the underlying page see them).
Additional notes:
- There are other places where we seem to be leaking keyup events.
- A separate bug... It looks like we're calling `exit()` on link-hints
  mode twice.
Diffstat (limited to 'content_scripts/mode.coffee')
| -rw-r--r-- | content_scripts/mode.coffee | 19 | 
1 files changed, 19 insertions, 0 deletions
| diff --git a/content_scripts/mode.coffee b/content_scripts/mode.coffee index 508b1b2c..49da03e2 100644 --- a/content_scripts/mode.coffee +++ b/content_scripts/mode.coffee @@ -144,6 +144,25 @@ class Mode          keyup: (event) =>            if KeyboardUtils.isPrintable event then @stopBubblingAndFalse else @stopBubblingAndTrue +    # if @options.suppressTrailingKeyEvents is set, then we suppress all key events until a subsquent +    # (non-repeat) keydown or keypress.  In particular, the intention is to catch keyup events for keys which +    # we have handled, but which otherwise might trigger page actions (if the page is listening for keyup +    # events). +    if @options.suppressTrailingKeyEvents +      @onExit -> +        handler = (event) -> +          if event.repeat +            false # Suppress event. +          else +            keyEventSuppressor.exit() +            true # Do not suppress event. + +        keyEventSuppressor = new Mode +          name: "suppress-trailing-key-events" +          keydown: handler +          keypress: handler +          keyup: -> handlerStack.stopBubblingAndFalse +      Mode.modes.push @      @setIndicator()      @logModes() | 
