[orca] Fall back on AtspiAction when synthesized click fails



commit a413bdce0a4f093d39ef451fe7e867d57d7e77ba
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Fri Jun 28 12:16:34 2019 -0400

    Fall back on AtspiAction when synthesized click fails

 src/orca/eventsynthesizer.py | 28 ++++++++++++++++++++++++++++
 src/orca/scripts/default.py  | 13 +++++++++++--
 2 files changed, 39 insertions(+), 2 deletions(-)
---
diff --git a/src/orca/eventsynthesizer.py b/src/orca/eventsynthesizer.py
index 832c0bc63..1b2f59990 100644
--- a/src/orca/eventsynthesizer.py
+++ b/src/orca/eventsynthesizer.py
@@ -280,3 +280,31 @@ def scrollToRightEdge(obj):
         return
 
     _scrollToLocation(obj, pyatspi.SCROLL_RIGHT_EDGE)
+
+def _performNamedAction(obj, name):
+    try:
+        action = obj.queryAction()
+    except NotImplementedError:
+        msg = "ERROR: Action interface not implemented for %s" % obj
+        debug.println(debug.LEVEL_INFO, msg, True)
+        return False
+
+    for i in range(action.nActions):
+        if action.getName(i).lower() == name.lower():
+            rv = action.doAction(i)
+            msg = "EVENT SYNTHESIZER: %s on %s result: %s" % (name, obj, rv)
+            debug.println(debug.LEVEL_INFO, msg, True)
+            return rv
+
+    msg = "INFO: %s not an available action for %s" % (name, obj)
+    debug.println(debug.LEVEL_INFO, msg, True)
+    return False
+
+def activateActionOn(obj):
+    return _performNamedAction(obj, "activate")
+
+def clickActionOn(obj):
+    return _performNamedAction(obj, "click")
+
+def pressActionOn(obj):
+    return _performNamedAction(obj, "press")
diff --git a/src/orca/scripts/default.py b/src/orca/scripts/default.py
index 7a13fd761..d5267e7ad 100644
--- a/src/orca/scripts/default.py
+++ b/src/orca/scripts/default.py
@@ -1305,8 +1305,17 @@ class Script(script.Script):
         """Performs a left mouse button click on the current item."""
 
         if self.flatReviewContext:
-            self.flatReviewContext.clickCurrent(1)
-            return True
+            if self.flatReviewContext.clickCurrent(1):
+                return True
+
+            obj = self.flatReviewContext.getCurrentAccessible()
+            if eventsynthesizer.clickActionOn(obj):
+                return True
+            if eventsynthesizer.pressActionOn(obj):
+                return True
+            if eventsynthesizer.activateActionOn(obj):
+                return True
+            return False
 
         if self.utilities.queryNonEmptyText(orca_state.locusOfFocus):
             if eventsynthesizer.clickCharacter(orca_state.locusOfFocus, 1):


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