[orca] Attempt to identify and ignore text insertions from page tab switches



commit 0795f7ceeecf143c2e2a4d55fd404e22392e0054
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Fri Apr 17 11:59:35 2020 -0400

    Attempt to identify and ignore text insertions from page tab switches
    
    VSCode (and potentially other apps) emits a text-insertion event each
    and every time the page tab is switched by the user. And the event
    contains the text for the entire file. We really shouldn't be speaking
    the entire file in response.

 src/orca/script_utilities.py | 10 ++++++++++
 src/orca/scripts/default.py  |  6 +++++-
 2 files changed, 15 insertions(+), 1 deletion(-)
---
diff --git a/src/orca/script_utilities.py b/src/orca/script_utilities.py
index 5197741e7..95d5ce3af 100644
--- a/src/orca/script_utilities.py
+++ b/src/orca/script_utilities.py
@@ -4936,6 +4936,16 @@ class Utilities:
         keyString, mods = self.lastKeyAndModifiers()
         return mods & keybindings.CTRL_MODIFIER_MASK
 
+    def lastInputEventWasPageSwitch(self):
+        keyString, mods = self.lastKeyAndModifiers()
+        if keyString.isnumeric():
+            return mods & keybindings.ALT_MODIFIER_MASK
+
+        if keyString in ["Page_Up", "Page_Down"]:
+            return mods & keybindings.CTRL_MODIFIER_MASK
+
+        return False
+
     def lastInputEventWasUnmodifiedArrow(self):
         keyString, mods = self.lastKeyAndModifiers()
         if not keyString in ["Left", "Right", "Up", "Down"]:
diff --git a/src/orca/scripts/default.py b/src/orca/scripts/default.py
index 8763b1e7d..242ed33f0 100644
--- a/src/orca/scripts/default.py
+++ b/src/orca/scripts/default.py
@@ -2697,7 +2697,11 @@ class Script(script.Script):
         # Because some implementations are broken.
         string = self.utilities.insertedText(event)
 
-        if self.utilities.lastInputEventWasCommand():
+        if self.utilities.lastInputEventWasPageSwitch():
+            msg = "DEFAULT: Insertion is believed to be due to page switch"
+            debug.println(debug.LEVEL_INFO, msg, True)
+            speakString = False
+        elif self.utilities.lastInputEventWasCommand():
             msg = "DEFAULT: Insertion is believed to be due to command"
             debug.println(debug.LEVEL_INFO, msg, True)
         elif self.utilities.isMiddleMouseButtonTextInsertionEvent(event):


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]