[orca] Fix for bug #645359 - Orca is not able to set the caret position within a WebKitGtk list item when u



commit 08c214bae138b3a151a5156bd69eef293fd4fba4
Author: Joanmarie Diggs <joanmarie diggs gmail com>
Date:   Mon Mar 21 00:57:45 2011 -0400

    Fix for bug #645359 - Orca is not able to set the caret position within a WebKitGtk list item when using structural navigation

 src/orca/scripts/toolkits/WebKitGtk/script.py      |   32 ++++++++++++++++++++
 .../toolkits/WebKitGtk/structural_navigation.py    |   18 +++++++++++
 2 files changed, 50 insertions(+), 0 deletions(-)
---
diff --git a/src/orca/scripts/toolkits/WebKitGtk/script.py b/src/orca/scripts/toolkits/WebKitGtk/script.py
index 1b70c7b..0057fc0 100644
--- a/src/orca/scripts/toolkits/WebKitGtk/script.py
+++ b/src/orca/scripts/toolkits/WebKitGtk/script.py
@@ -26,6 +26,7 @@ __copyright__ = "Copyright (c) 2010 Joanmarie Diggs"
 __license__   = "LGPL"
 
 import pyatspi
+import pyatspi.utils as utils
 
 import orca.scripts.default as default
 import orca.orca as orca
@@ -299,3 +300,34 @@ class Script(default.Script):
                 return False
 
         return True
+
+    def setCaretAtStart(self, obj):
+        """Attempts to set the caret at the specified offset in obj. Because
+        this is not always possible, this method will attempt to locate the
+        first place inside of obj in which the caret can be positioned.
+
+        Arguments:
+        - obj: the accessible object in which the caret should be placed.
+
+        Returns the object and offset in which we were able to set the caret.
+        Otherwise, None if we could not find a text object, and -1 if we were
+        not able to set the caret.
+        """
+
+        def implementsText(obj):
+            return 'Text' in utils.listInterfaces(obj)
+
+        child = obj
+        if not implementsText(obj):
+            child = utils.findDescendant(obj, implementsText)
+            if not child:
+                return None, -1
+
+        index = -1
+        text = child.queryText()
+        for i in xrange(text.characterCount):
+            if text.setCaretOffset(i):
+                index = i
+                break
+
+        return child, index
diff --git a/src/orca/scripts/toolkits/WebKitGtk/structural_navigation.py b/src/orca/scripts/toolkits/WebKitGtk/structural_navigation.py
index f3849ff..36df733 100644
--- a/src/orca/scripts/toolkits/WebKitGtk/structural_navigation.py
+++ b/src/orca/scripts/toolkits/WebKitGtk/structural_navigation.py
@@ -27,6 +27,7 @@ __license__   = "LGPL"
 
 import pyatspi
 
+import orca.orca as orca
 import orca.structural_navigation as structural_navigation
 
 ########################################################################
@@ -60,3 +61,20 @@ class StructuralNavigation(structural_navigation.StructuralNavigation):
             obj = obj[0]
 
         return [obj, 0]
+
+    def _setCaretPosition(self, obj, characterOffset):
+        """Sets the caret at the specified offset within obj.
+
+        Arguments:
+        - obj: the accessible object in which the caret should be
+          positioned.
+        - characterOffset: the offset at which to position the caret.
+        """
+
+        if characterOffset == 0:
+            child, offset = self._script.setCaretAtStart(obj)
+            orca.setLocusOfFocus(None, child, False)
+            return
+
+        structural_navigation.StructuralNavigation._setCaretPosition(
+            self, obj, characterOffset)



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