|
1 | 1 | #_UIAHandler.py |
2 | 2 | #A part of NonVisual Desktop Access (NVDA) |
3 | | -#Copyright (C) 2011-2019 NV Access Limited, Joseph Lee, Babbage B.V. |
| 3 | +#Copyright (C) 2011-2019 NV Access Limited, Joseph Lee, Babbage B.V., Leonard de Ruijter |
4 | 4 | #This file is covered by the GNU General Public License. |
5 | 5 | #See the file COPYING for more details. |
6 | 6 |
|
|
144 | 144 | UIA_SelectionItem_ElementAddedToSelectionEventId:"stateChange", |
145 | 145 | UIA_SelectionItem_ElementRemovedFromSelectionEventId:"stateChange", |
146 | 146 | #UIA_MenuModeEndEventId:"menuModeEnd", |
147 | | - #UIA_Text_TextSelectionChangedEventId:"caret", |
148 | 147 | UIA_ToolTipOpenedEventId:"UIA_toolTipOpened", |
149 | 148 | #UIA_AsyncContentLoadedEventId:"documentLoadComplete", |
150 | 149 | #UIA_ToolTipClosedEventId:"hide", |
151 | 150 | UIA_Window_WindowOpenedEventId:"UIA_window_windowOpen", |
152 | 151 | UIA_SystemAlertEventId:"UIA_systemAlert", |
153 | 152 | } |
154 | 153 |
|
| 154 | +autoSelectDetectionAvailable = False |
155 | 155 | if winVersion.isWin10(): |
156 | | - UIAEventIdsToNVDAEventNames[UIA_Text_TextChangedEventId] = "textChange" |
| 156 | + UIAEventIdsToNVDAEventNames.update({ |
| 157 | + UIA_Text_TextChangedEventId: "textChange", |
| 158 | + UIA_Text_TextSelectionChangedEventId: "caret", |
| 159 | + }) |
| 160 | + autoSelectDetectionAvailable = True |
157 | 161 |
|
158 | 162 | ignoreWinEventsMap = { |
159 | 163 | UIA_AutomationPropertyChangedEventId: list(UIAPropertyIdsToNVDAEventNames.keys()), |
@@ -273,20 +277,25 @@ def IUIAutomationEventHandler_HandleAutomationEvent(self,sender,eventID): |
273 | 277 | NVDAEventName=UIAEventIdsToNVDAEventNames.get(eventID,None) |
274 | 278 | if not NVDAEventName: |
275 | 279 | return |
276 | | - if not self.isNativeUIAElement(sender): |
| 280 | + focus = api.getFocusObject() |
| 281 | + import NVDAObjects.UIA |
| 282 | + if ( |
| 283 | + isinstance(focus, NVDAObjects.UIA.UIA) |
| 284 | + and self.clientObject.compareElements(focus.UIAElement, sender) |
| 285 | + ): |
| 286 | + pass |
| 287 | + elif not self.isNativeUIAElement(sender): |
277 | 288 | return |
278 | 289 | window=self.getNearestWindowHandle(sender) |
279 | 290 | if window and not eventHandler.shouldAcceptEvent(NVDAEventName,windowHandle=window): |
280 | 291 | return |
281 | | - import NVDAObjects.UIA |
282 | 292 | obj=NVDAObjects.UIA.UIA(UIAElement=sender) |
283 | 293 | if ( |
284 | 294 | not obj |
285 | 295 | or (NVDAEventName=="gainFocus" and not obj.shouldAllowUIAFocusEvent) |
286 | 296 | or (NVDAEventName=="liveRegionChange" and not obj._shouldAllowUIALiveRegionChangeEvent) |
287 | 297 | ): |
288 | 298 | return |
289 | | - focus=api.getFocusObject() |
290 | 299 | if obj==focus: |
291 | 300 | obj=focus |
292 | 301 | eventHandler.queueEvent(NVDAEventName,obj) |
@@ -328,16 +337,21 @@ def IUIAutomationPropertyChangedEventHandler_HandlePropertyChangedEvent(self,sen |
328 | 337 | NVDAEventName=UIAPropertyIdsToNVDAEventNames.get(propertyId,None) |
329 | 338 | if not NVDAEventName: |
330 | 339 | return |
331 | | - if not self.isNativeUIAElement(sender): |
| 340 | + focus = api.getFocusObject() |
| 341 | + import NVDAObjects.UIA |
| 342 | + if ( |
| 343 | + isinstance(focus, NVDAObjects.UIA.UIA) |
| 344 | + and self.clientObject.compareElements(focus.UIAElement, sender) |
| 345 | + ): |
| 346 | + pass |
| 347 | + elif not self.isNativeUIAElement(sender): |
332 | 348 | return |
333 | 349 | window=self.getNearestWindowHandle(sender) |
334 | 350 | if window and not eventHandler.shouldAcceptEvent(NVDAEventName,windowHandle=window): |
335 | 351 | return |
336 | | - import NVDAObjects.UIA |
337 | 352 | obj=NVDAObjects.UIA.UIA(UIAElement=sender) |
338 | 353 | if not obj: |
339 | 354 | return |
340 | | - focus=api.getFocusObject() |
341 | 355 | if obj==focus: |
342 | 356 | obj=focus |
343 | 357 | eventHandler.queueEvent(NVDAEventName,obj) |
|
0 commit comments