4
4
#This file is covered by the GNU General Public License.
5
5
#See the file COPYING for more details.
8
7
from comtypes import COMError
10
9
from NVDAObjects.IAccessible import IAccessible
11
10
import eventHandler
11
from scriptHandler import isScriptWaiting
13
13
class Client(IAccessible):
15
def _get__containedWidget(self):
16
widget = self.firstChild
22
# There is only one child, so this is probably a widget container.
26
if wnext.firstChild.role == controlTypes.ROLE_SCROLLBAR:
27
# There is only one child plus a scrollbar, so this is probably a widget container.
29
except AttributeError:
32
# This is not a widget container.
15
35
def event_gainFocus(self):
16
36
if eventHandler.isPendingEvents("gainFocus"):
19
# If there is only one child, this is probably a widget container.
20
child = self.firstChild
21
if child and not child.next:
22
# Redirect the focus, since QT doesn't do it properly.
39
widget = self._containedWidget
41
# This is a widget container.
42
# Redirect the focus to the contained widget, since QT doesn't do it properly.
23
43
self.event_focusEntered()
24
eventHandler.executeEvent("gainFocus", child)
44
eventHandler.executeEvent("gainFocus", widget)
27
47
return super(Client, self).event_gainFocus()
52
72
return super(Container, self).event_gainFocus()
75
class TableRow(Container):
80
def _get_activeChild(self):
81
# QT doesn't do accFocus properly, so find the active child ourselves.
82
child = self.firstChild
85
if controlTypes.STATE_FOCUSED in states:
91
class TableCell(IAccessible):
95
def script_nextColumn(self,gesture):
97
if not isScriptWaiting():
99
if next and controlTypes.STATE_FOCUSED in next.states:
100
eventHandler.executeEvent("gainFocus", next)
102
def script_previousColumn(self,gesture):
104
if not isScriptWaiting():
105
previous=self.previous
106
if previous and controlTypes.STATE_FOCUSED in previous.states:
107
eventHandler.executeEvent("gainFocus", previous)
110
"kb:tab": "nextColumn",
111
"kb:rightArrow": "nextColumn",
112
"kb:shift+tab": "previousColumn",
113
"kb:leftArrow": "previousColumn",
54
117
class TreeViewItem(IAccessible):
55
RE_POSITION_INFO = re.compile(r"L(?P<level>\d+), (?P<indexInGroup>\d+) of (?P<similarItemsInGroup>\d+) with \d+")
57
# The description and value should not be user visible.
61
def _get_positionInfo(self):
62
# QT encodes the position info in the accDescription.
64
desc = self.IAccessibleObject.accDescription(self.IAccessibleChildID)
66
return super(TreeViewItem, self).positionInfo
68
m = self.RE_POSITION_INFO.match(desc)
72
return super(TreeViewItem, self).positionInfo
121
hasEncodedAccDescription=True
74
123
class Menu(IAccessible):
75
124
# QT incorrectly fires a focus event on the parent menu immediately after (correctly) firing focus on the menu item.