[orca] Fix several issues in character echo



commit 87930100dba3cd2ed9c49bf5f78ea7994f3038be
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Fri Jun 6 15:33:02 2014 -0400

    Fix several issues in character echo

 src/orca/script_utilities.py                       |   32 +++++++-------
 src/orca/scripts/toolkits/clutter/Makefile.am      |    3 +-
 src/orca/scripts/toolkits/clutter/script.py        |    4 ++
 .../scripts/toolkits/clutter/script_utilities.py   |   42 ++++++++++++++++++++
 4 files changed, 64 insertions(+), 17 deletions(-)
---
diff --git a/src/orca/script_utilities.py b/src/orca/script_utilities.py
index 7982aa1..d0f18e4 100644
--- a/src/orca/script_utilities.py
+++ b/src/orca/script_utilities.py
@@ -1973,22 +1973,22 @@ class Utilities:
         if not orca_state.locusOfFocus or not settings.enableEchoByCharacter:
             return False
 
-        # The check here in English is something like this: "If this
-        # character echo is enabled, then character echo is likely to
-        # happen if the locus of focus is a focusable editable text
-        # area or terminal and neither of the Ctrl, Alt, or Orca
-        # modifiers are pressed.  If that's the case, then character
-        # echo will kick in for us."
-        #
-        return (self.isTextArea(orca_state.locusOfFocus)\
-                     or orca_state.locusOfFocus.getRole() \
-                        == pyatspi.ROLE_ENTRY) \
-                and (orca_state.locusOfFocus.getRole() \
-                     == pyatspi.ROLE_TERMINAL \
-                     or (not self.isReadOnlyTextArea(orca_state.locusOfFocus) \
-                         and (orca_state.locusOfFocus.getState().contains( \
-                                  pyatspi.STATE_FOCUSABLE)))) \
-                and not (event.modifiers & keybindings.ORCA_CTRL_MODIFIER_MASK)
+        if len(event.event_string) != 1 \
+           or not event.event_string.isalnum() \
+           or event.modifiers & keybindings.ORCA_CTRL_MODIFIER_MASK:
+            return False
+
+        obj = orca_state.locusOfFocus
+        role = obj.getRole()
+        if role == pyatspi.ROLE_TERMINAL:
+            return True
+        if role == pyatspi.ROLE_PASSWORD_TEXT:
+            return False
+
+        if obj.getState().contains(pyatspi.STATE_EDITABLE):
+            return True
+
+        return False
 
     def wordAtCoords(self, acc, x, y):
         """Get the word at the given coords in the accessible.
diff --git a/src/orca/scripts/toolkits/clutter/Makefile.am b/src/orca/scripts/toolkits/clutter/Makefile.am
index 8294730..caa9e81 100644
--- a/src/orca/scripts/toolkits/clutter/Makefile.am
+++ b/src/orca/scripts/toolkits/clutter/Makefile.am
@@ -1,6 +1,7 @@
 orca_python_PYTHON = \
        __init__.py \
-       script.py
+       script.py \
+       script_utilities.py
 
 orca_pythondir=$(pkgpythondir)/scripts/toolkits/clutter
 
diff --git a/src/orca/scripts/toolkits/clutter/script.py b/src/orca/scripts/toolkits/clutter/script.py
index b485e0b..fe03c90 100644
--- a/src/orca/scripts/toolkits/clutter/script.py
+++ b/src/orca/scripts/toolkits/clutter/script.py
@@ -30,6 +30,7 @@ from gi.repository import Gdk
 
 import orca.scripts.default as default
 import orca.debug as debug
+from .script_utilities import Utilities
 
 # Set with non printable unicode categories. Full table:
 # http://www.fileformat.info/info/unicode/category/index.htm
@@ -78,6 +79,9 @@ class Script(default.Script):
     def __init__(self, app):
         default.Script.__init__(self, app)
 
+    def getUtilities(self):
+        return Utilities(self)
+
     def checkKeyboardEventData(self, keyboardEvent):
         """Processes the given keyboard event.
 
diff --git a/src/orca/scripts/toolkits/clutter/script_utilities.py 
b/src/orca/scripts/toolkits/clutter/script_utilities.py
new file mode 100644
index 0000000..a763b51
--- /dev/null
+++ b/src/orca/scripts/toolkits/clutter/script_utilities.py
@@ -0,0 +1,42 @@
+# Orca
+#
+# Copyright (C) 2014 Igalia, S.L.
+#
+# Author: Joanmarie Diggs <jdiggs igalia com>
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the
+# Free Software Foundation, Inc., Franklin Street, Fifth Floor,
+# Boston MA  02110-1301 USA.
+
+__id__        = "$Id$"
+__version__   = "$Revision$"
+__date__      = "$Date$"
+__copyright__ = "Copyright (c) 2014 Igalia, S.L."
+__license__   = "LGPL"
+
+import orca.script_utilities as script_utilities
+
+class Utilities(script_utilities.Utilities):
+
+    def __init__(self, script):
+        script_utilities.Utilities.__init__(self, script)
+
+    def willEchoCharacter(self, event):
+        """Given a keyboard event containing an alphanumeric key,
+        determine if the script is likely to echo it as a character."""
+
+        # There is currently a bug in which we don't get the inserted text
+        # from the object:text-changed:insert event. We cannot echo what we
+        # don't receive.
+        return False


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