Package NVDAObjects :: Package IAccessible :: Module qt
[hide private]
[frames] | no frames]

Source Code for Module NVDAObjects.IAccessible.qt

  1  #NVDAObjects/IAccessible/qt.py 
  2  #A part of NonVisual Desktop Access (NVDA) 
  3  #Copyright (C) 2006-2009 NVDA Contributors <http://www.nvda-project.org/> 
  4  #This file is covered by the GNU General Public License. 
  5  #See the file COPYING for more details. 
  6   
  7  from comtypes import COMError 
  8  import controlTypes 
  9  from NVDAObjects.IAccessible import IAccessible 
 10  import eventHandler 
 11  from scriptHandler import isScriptWaiting 
 12   
13 -class Client(IAccessible):
14
15 - def _get__containedWidget(self):
16 widget = self.firstChild 17 if not widget: 18 return None 19 20 wnext = widget.next 21 if not wnext: 22 # There is only one child, so this is probably a widget container. 23 return widget 24 25 try: 26 if wnext.firstChild.role == controlTypes.ROLE_SCROLLBAR: 27 # There is only one child plus a scrollbar, so this is probably a widget container. 28 return widget 29 except AttributeError: 30 pass 31 32 # This is not a widget container. 33 return None
34
35 - def event_gainFocus(self):
36 if eventHandler.isPendingEvents("gainFocus"): 37 return 38 39 widget = self._containedWidget 40 if widget: 41 # This is a widget container. 42 # Redirect the focus to the contained widget, since QT doesn't do it properly. 43 self.event_focusEntered() 44 eventHandler.executeEvent("gainFocus", widget) 45 return 46 47 return super(Client, self).event_gainFocus()
48
49 -class Container(IAccessible):
50
51 - def _get_activeChild(self):
52 # QT doesn't do accFocus properly, so find the active child ourselves. 53 child = self.firstChild 54 while child: 55 states = child.states 56 if controlTypes.STATE_FOCUSED in states or controlTypes.STATE_SELECTED in states: 57 return child 58 child = child.next 59 return None
60
61 - def event_gainFocus(self):
62 if eventHandler.isPendingEvents("gainFocus"): 63 return 64 65 child = self.activeChild 66 if child: 67 # QT doesn't fire focus on the active child as it should, so redirect the focus. 68 self.event_focusEntered() 69 eventHandler.executeEvent("gainFocus", child) 70 return 71 72 return super(Container, self).event_gainFocus()
73 74
75 -class TableRow(Container):
76 77 value=None 78 description=None 79
80 - def _get_activeChild(self):
81 # QT doesn't do accFocus properly, so find the active child ourselves. 82 child = self.firstChild 83 while child: 84 states = child.states 85 if controlTypes.STATE_FOCUSED in states: 86 return child 87 child = child.next 88 return None
89 90
91 -class TableCell(IAccessible):
92 93 value=None 94
95 - def script_nextColumn(self,gesture):
96 gesture.send() 97 if not isScriptWaiting(): 98 next=self.next 99 if next and controlTypes.STATE_FOCUSED in next.states: 100 eventHandler.executeEvent("gainFocus", next)
101
102 - def script_previousColumn(self,gesture):
103 gesture.send() 104 if not isScriptWaiting(): 105 previous=self.previous 106 if previous and controlTypes.STATE_FOCUSED in previous.states: 107 eventHandler.executeEvent("gainFocus", previous)
108 109 __gestures = { 110 "kb:tab": "nextColumn", 111 "kb:rightArrow": "nextColumn", 112 "kb:shift+tab": "previousColumn", 113 "kb:leftArrow": "previousColumn", 114 }
115 116
117 -class TreeViewItem(IAccessible):
118 119 value = None 120 121 hasEncodedAccDescription=True
122 127
128 -class LayeredPane(IAccessible):
129 # QT < 4.6 uses ROLE_SYSTEM_IPADDRESS for layered pane. 130 # See QT task 258413. 131 role = controlTypes.ROLE_LAYEREDPANE
132
133 -class Application(IAccessible):
134 # QT sets the path of the application in the description, which is irrelevant to the user. 135 description = None 136
137 - def _get_states(self):
138 states = super(Application, self)._get_states() 139 # The application should not have the focused state. 140 # Otherwise, checks for the focused state will always hit the application and assume the focus is valid. 141 states.discard(controlTypes.STATE_FOCUSED) 142 return states
143