OSDN Git Service

No longer always fall back to using the MSAA childID and accChildCount as position...
authorMichael Curran <mick@kulgan.net>
Wed, 22 Sep 2010 19:30:24 +0000 (05:30 +1000)
committerMichael Curran <mick@kulgan.net>
Wed, 22 Sep 2010 19:30:24 +0000 (05:30 +1000)
*IAccessible NVDAObject: add a 'allowIAccessibleChildIDAndChildCountForPositionInfo' class variable, which the positionInfo property now checks. If true then it will fall back to using childID and accchildCount, if there is no richer IAccessible2 info available. This class variable is set to False by default.
*TaskListIcon IAccessible NVDAObject: set allowIAccessibleChildIDAndChildCountForPositionInfo to True as position info from MSAA is always correct, and quite useful gere,
*SysListView32ListItem IAccessible NVDAObject: rewrite the positionInfo property so that it does not rely on the super implementation, but instead specifically grabs what it needs.

source/NVDAObjects/IAccessible/__init__.py
source/NVDAObjects/IAccessible/sysListView32.py

index e8ba169..bda2521 100644 (file)
@@ -1035,6 +1035,8 @@ the NVDAObject for IAccessible
                        except:\r
                                log.debugWarning("IAccessible2::scrollTo failed", exc_info=True)\r
 \r
+       allowIAccessibleChildIDAndChildCountForPositionInfo=False #: if true position info should fall back to using the childID and the parent's accChildCount for position information if there is nothing better available.\r
+\r
        def _get_positionInfo(self):\r
                info={}\r
                level=similarItemsInGroup=indexInGroup=0\r
@@ -1044,11 +1046,12 @@ the NVDAObject for IAccessible
                                gotVars=True\r
                        except COMError:\r
                                pass\r
-               if indexInGroup==0:\r
+               if self.allowIAccessibleChildIDAndChildCountForPositionInfo and indexInGroup==0:\r
                        indexInGroup=self.IAccessibleChildID\r
-               if indexInGroup>0 and similarItemsInGroup<indexInGroup:\r
-                       parent=self.parent=self.parent\r
-                       similarItemsInGroup=parent.childCount\r
+               if self.allowIAccessibleChildIDAndChildCountForPositionInfo and indexInGroup>0 and similarItemsInGroup<indexInGroup:\r
+                       parent=self.parent\r
+                       if parent:\r
+                               similarItemsInGroup=parent.childCount\r
                if level>0:\r
                        info['level']=level\r
                if indexInGroup<=similarItemsInGroup and indexInGroup>0:\r
@@ -1384,6 +1387,8 @@ class TaskList(IAccessible):
 \r
 class TaskListIcon(IAccessible):\r
 \r
+       allowIAccessibleChildIDAndChildCountForPositionInfo=True\r
+\r
        def _get_role(self):\r
                return controlTypes.ROLE_ICON\r
 \r
index 52d22cf..402eb5f 100644 (file)
@@ -231,10 +231,9 @@ class ListItem(IAccessible):
                return value\r
 \r
        def _get_positionInfo(self):\r
-               info=super(ListItem,self)._get_positionInfo()\r
+               index=self.IAccessibleChildID\r
                totalCount=winUser.sendMessage(self.windowHandle,LVM_GETITEMCOUNT,0,0)\r
-               info['similarItemsInGroup']=totalCount\r
-               return info\r
+               return dict(indexInGroup=index,similarItemsInGroup=totalCount) \r
 \r
        def event_stateChange(self):\r
                if self.hasFocus:\r