From f407fe2feba1ffa4ac3fdd50e431ac51b8ec630f Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Mon, 9 Mar 2015 08:49:37 +0000 Subject: Pass keyup events after entering link-hint mode. The page (or another extension) sees keydown events (such as shift) before entering link-hint mode. So we need to also pass the corresponding keyup events. Fixes #1522. --- content_scripts/link_hints.coffee | 1 + content_scripts/mode.coffee | 10 ++++++++++ 2 files changed, 11 insertions(+) (limited to 'content_scripts') diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee index f904c7d5..72fde9e1 100644 --- a/content_scripts/link_hints.coffee +++ b/content_scripts/link_hints.coffee @@ -68,6 +68,7 @@ LinkHints = @hintMode = new Mode name: "hint/#{mode.name}" badge: "#{mode.key}?" + passInitialKeyupEvents: true keydown: @onKeyDownInMode.bind(this, hintMarkers), # trap all key events keypress: -> false diff --git a/content_scripts/mode.coffee b/content_scripts/mode.coffee index fa583a1c..bded402c 100644 --- a/content_scripts/mode.coffee +++ b/content_scripts/mode.coffee @@ -120,6 +120,16 @@ class Mode @registerStateChange?() registerKeyQueue: ({ keyQueue: keyQueue }) => @alwaysContinueBubbling => @keyQueue = keyQueue + # If @options.passInitialKeyupEvents is set, then we pass initial non-printable keyup events to the page + # or to other extensions (because the corresponding keydown events were passed). This is used when + # activating link hints, see #1522. + if @options.passInitialKeyupEvents + @push + _name: "mode-#{@id}/passInitialKeyupEvents" + keydown: => @alwaysContinueBubbling -> handlerStack.remove() + keyup: (event) => + if KeyboardUtils.isPrintable event then @stopBubblingAndFalse else @stopBubblingAndTrue + Mode.modes.push @ Mode.updateBadge() @logModes() -- cgit v1.2.3