[orca] Fix for bgo#588471 - Orca's clicking functionality should click on the locusOfFocus when not in flat



commit e1ea8a23212a68e8b65d0f80e662c98d98220685
Author: Joanmarie Diggs <joanmarie diggs gmail com>
Date:   Fri Jul 17 19:08:01 2009 -0400

    Fix for bgo#588471 - Orca's clicking functionality should click on the locusOfFocus when not in flat review

 src/orca/default.py          |   32 ++++++++++++++++++++++++++++++--
 src/orca/eventsynthesizer.py |   19 +++++++++++++++++++
 2 files changed, 49 insertions(+), 2 deletions(-)
---
diff --git a/src/orca/default.py b/src/orca/default.py
index 783174b..13addfb 100644
--- a/src/orca/default.py
+++ b/src/orca/default.py
@@ -5111,13 +5111,41 @@ class Script(script.Script):
     def leftClickReviewItem(self, inputEvent=None):
         """Performs a left mouse button click on the current item."""
 
-        self.getFlatReviewContext().clickCurrent(1)
+        if self.flatReviewContext:
+            self.flatReviewContext.clickCurrent(1)
+        else:
+            try:
+                eventsynthesizer.clickCharacter(orca_state.locusOfFocus, 1)
+            except:
+                try:
+                    eventsynthesizer.clickObject(orca_state.locusOfFocus, 1)
+                except:
+                    # Translators: Orca has a command that allows the user
+                    # to move the mouse pointer to the current object. If
+                    # for some reason Orca cannot identify the current
+                    # location, it will speak this message.
+                    #
+                    speech.speak(_("Could not find current location."))
         return True
 
     def rightClickReviewItem(self, inputEvent=None):
         """Performs a right mouse button click on the current item."""
 
-        self.getFlatReviewContext().clickCurrent(3)
+        if self.flatReviewContext:
+            self.flatReviewContext.clickCurrent(3)
+        else:
+            try:
+                eventsynthesizer.clickCharacter(orca_state.locusOfFocus, 3)
+            except:
+                try:
+                    eventsynthesizer.clickObject(orca_state.locusOfFocus, 3)
+                except:
+                    # Translators: Orca has a command that allows the user
+                    # to move the mouse pointer to the current object. If
+                    # for some reason Orca cannot identify the current
+                    # location, it will speak this message.
+                    #
+                    speech.speak(_("Could not find current location."))
         return True
 
     def reviewCurrentLine(self, inputEvent):
diff --git a/src/orca/eventsynthesizer.py b/src/orca/eventsynthesizer.py
index a438830..68c12a5 100644
--- a/src/orca/eventsynthesizer.py
+++ b/src/orca/eventsynthesizer.py
@@ -87,6 +87,25 @@ def routeToPoint(x, y, eventName="abs"):
     """
     generateMouseEvent(x, y, eventName)
 
+def clickCharacter(obj, button):
+    """Performs a button click on the current character
+
+    Arguments:
+    - obj: the Accessible which implements the accessible text
+      interface
+    - button: an integer representing the mouse button number
+    """
+    text = obj.queryText()
+    # We try to click to the left of center.  This is to
+    # handle toolkits that will offset the caret position to
+    # the right if you click dead on center of a character.
+    #
+    extents = text.getCharacterExtents(text.caretOffset,
+                                       pyatspi.DESKTOP_COORDS)
+    x = max(extents[0], extents[0] + (extents[2] / 2) - 1)
+    y = extents[1] + extents[3] / 2
+    generateMouseEvent(x, y, "b%dc" % button)
+
 def clickObject(obj, button):
     """Performs a button click on the given Accessible.
 



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