[orca] Hack around other app/toolkit broken password text insertion events



commit db0a77b72bf15497a279ab9d44258e00d6027ccb
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Mon Feb 15 01:33:08 2016 -0500

    Hack around other app/toolkit broken password text insertion events

 src/orca/script_utilities.py |   26 +++++++++++++++++++++++++-
 1 files changed, 25 insertions(+), 1 deletions(-)
---
diff --git a/src/orca/script_utilities.py b/src/orca/script_utilities.py
index 1ba63b2..339822c 100644
--- a/src/orca/script_utilities.py
+++ b/src/orca/script_utilities.py
@@ -2290,7 +2290,31 @@ class Utilities:
         return None
 
     def insertedText(self, event):
-        return event.any_data
+        if event.any_data:
+            return event.any_data
+
+        msg = "ERROR: Broken text insertion event"
+        debug.println(debug.LEVEL_INFO, msg, True)
+
+        try:
+            role = event.source.getRole()
+        except:
+            msg = "ERROR: Exception getting role of %s" % event.source
+            debug.println(debug.LEVEL_INFO, msg, True)
+            role = None
+
+        if role == pyatspi.ROLE_PASSWORD_TEXT:
+            text = self.queryNonEmptyText(event.source)
+            if text:
+                string = text.getText(0, -1)
+                if string:
+                    msg = "HACK: Returning last char in '%s'" % string
+                    debug.println(debug.LEVEL_INFO, msg, True)
+                    return string[-1]
+
+        msg = "FAIL: Unable to correct broken text insertion event"
+        debug.println(debug.LEVEL_INFO, msg, True)
+        return ""
 
     def selectedText(self, obj):
         """Get the text selection for the given object.


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