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

Source Code for Module NVDAObjects.IAccessible.adobeFlash

 1  #NVDAObjects/IAccessible/adobeFlash.py 
 2  #A part of NonVisual Desktop Access (NVDA) 
 3  #Copyright (C) 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  import winUser 
 8  import oleacc 
 9  from . import IAccessible, getNVDAObjectFromEvent 
10  from NVDAObjects import NVDAObjectTextInfo 
11  from NVDAObjects.behaviors import EditableTextWithoutAutoSelectDetection 
12  from comtypes import COMError, IServiceProvider, hresult 
13  from comtypes.gen.FlashAccessibility import ISimpleTextSelection, IFlashAccessibility 
14  from logHandler import log 
15   
16 -class InputTextFieldTextInfo(NVDAObjectTextInfo):
17
18 - def _getStoryText(self):
19 return self.obj.value or ""
20
21 - def _getRawSelectionOffsets(self):
22 try: 23 return self.obj.ISimpleTextSelectionObject.GetSelection() 24 except COMError, e: 25 if e.hresult == hresult.E_FAIL: 26 # The documentation says that an empty field should return 0 for both values, but instead, we seem to get E_FAIL. 27 # An empty field still has a valid caret. 28 return 0, 0 29 else: 30 raise RuntimeError 31 except AttributeError: 32 raise RuntimeError
33
34 - def _getCaretOffset(self):
35 # We want the active (moving) end of the selection. 36 return self._getRawSelectionOffsets()[1]
37
38 - def _getSelectionOffsets(self):
39 # This might be a backwards selection, but for now, we should always return the values in ascending order. 40 return sorted(self._getRawSelectionOffsets())
41
42 -class InputTextField(EditableTextWithoutAutoSelectDetection, IAccessible):
43 TextInfo = InputTextFieldTextInfo
44
45 -class Root(IAccessible):
46
47 - def _get_presentationType(self):
48 return self.presType_content
49 53 54 #Flash root client has broken accParent, force to return the flash root window root IAccessible
55 - def _get_parent(self):
56 return getNVDAObjectFromEvent(self.windowHandle,0,0)
57
58 -def findExtraOverlayClasses(obj, clsList):
59 """Determine the most appropriate class if this is a Flash object. 60 This works similarly to L{NVDAObjects.NVDAObject.findOverlayClasses} except that it never calls any other findOverlayClasses method. 61 """ 62 try: 63 servProv = obj.IAccessibleObject.QueryInterface(IServiceProvider) 64 except COMError: 65 return 66 67 # Check whether this is the Flash root accessible. 68 if obj.IAccessibleRole == oleacc.ROLE_SYSTEM_CLIENT: 69 try: 70 servProv.QueryService(IFlashAccessibility._iid_, IFlashAccessibility) 71 clsList.append(Root) 72 except COMError: 73 pass 74 # If this is a client and IFlashAccessibility wasn't present, this is not a Flash object. 75 return 76 77 # Check whether this is a Flash input text field. 78 try: 79 # We have to fetch ISimpleTextSelectionObject in order to check whether this is an input text field, so store it on the instance. 80 obj.ISimpleTextSelectionObject = servProv.QueryService(ISimpleTextSelection._iid_, ISimpleTextSelection) 81 clsList.append(InputTextField) 82 except COMError: 83 pass
84