Skip to content

Commit dd9ed2d

Browse files
authored
Merge ab80d9f into 1af8775
2 parents 1af8775 + ab80d9f commit dd9ed2d

File tree

5 files changed

+49
-26
lines changed

5 files changed

+49
-26
lines changed

source/NVDAObjects/UIA/__init__.py

+14-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,15 @@
2828
from UIAUtils import *
2929
from NVDAObjects.window import Window
3030
from NVDAObjects import NVDAObjectTextInfo, InvalidNVDAObject
31-
from NVDAObjects.behaviors import ProgressBar, EditableTextWithoutAutoSelectDetection, Dialog, Notification, EditableTextWithSuggestions, ToolTip
31+
from NVDAObjects.behaviors import (
32+
ProgressBar,
33+
EditableTextWithoutAutoSelectDetection,
34+
EditableTextWithAutoSelectDetection,
35+
Dialog,
36+
Notification,
37+
EditableTextWithSuggestions,
38+
ToolTip
39+
)
3240
import braille
3341
import locationHelper
3442
import ui
@@ -877,7 +885,10 @@ def findOverlayClasses(self,clsList):
877885
winConsoleUIA.findExtraOverlayClasses(self, clsList)
878886
# Add editableText support if UIA supports a text pattern
879887
if self.TextInfo==UIATextInfo:
880-
clsList.append(EditableTextWithoutAutoSelectDetection)
888+
if UIAHandler.autoSelectDetectionAvailable:
889+
clsList.append(EditableTextWithAutoSelectDetection)
890+
else:
891+
clsList.append(EditableTextWithoutAutoSelectDetection)
881892

882893
clsList.append(UIA)
883894

@@ -1461,7 +1472,7 @@ def event_UIA_elementSelected(self):
14611472
self.event_stateChange()
14621473

14631474
def event_valueChange(self):
1464-
if isinstance(self, EditableTextWithoutAutoSelectDetection):
1475+
if issubclass(self.TextInfo, UIATextInfo):
14651476
return
14661477
return super(UIA, self).event_valueChange()
14671478

source/NVDAObjects/window/winword.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -1432,6 +1432,13 @@ def script_changeLineSpacing(self,gesture):
14321432
# Translators: a message when switching to 1.5 line spaceing in Microsoft word
14331433
ui.message(_("1.5 line spacing"))
14341434

1435+
def initOverlayClass(self):
1436+
if isinstance(self, EditableTextWithoutAutoSelectDetection):
1437+
self.bindGesture("kb:alt+shift+home", "caret_changeSelection")
1438+
self.bindGesture("kb:alt+shift+end", "caret_changeSelection")
1439+
self.bindGesture("kb:alt+shift+pageUp", "caret_changeSelection",)
1440+
self.bindGesture("kb:alt+shift+pageDown", "caret_changeSelection",)
1441+
14351442
__gestures = {
14361443
"kb:control+[":"increaseDecreaseFontSize",
14371444
"kb:control+]":"increaseDecreaseFontSize",
@@ -1459,10 +1466,6 @@ def script_changeLineSpacing(self,gesture):
14591466
"kb:control+5":"changeLineSpacing",
14601467
"kb:tab": "tab",
14611468
"kb:shift+tab": "tab",
1462-
"kb:alt+shift+home":"caret_changeSelection",
1463-
"kb:alt+shift+end":"caret_changeSelection",
1464-
"kb:alt+shift+pageUp":"caret_changeSelection",
1465-
"kb:alt+shift+pageDown":"caret_changeSelection",
14661469
"kb:control+pageUp": "caret_moveByLine",
14671470
"kb:control+pageDown": "caret_moveByLine",
14681471
}

source/UIABrowseMode.py

-5
Original file line numberDiff line numberDiff line change
@@ -444,8 +444,3 @@ def __contains__(self,obj):
444444
except LookupError:
445445
return False
446446
return True
447-
448-
def event_caret(self,obj,nextHandler):
449-
pass
450-
451-

source/UIAHandler.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
#UIAHandler.py
2-
#A part of NonVisual Desktop Access (NVDA)
3-
#Copyright (C) 2008-2018 NV Access Limited, Joseph Lee
4-
#This file is covered by the GNU General Public License.
5-
#See the file COPYING for more details.
1+
# UIAHandler.py
2+
# A part of NonVisual Desktop Access (NVDA)
3+
# Copyright (C) 2008-2018 NV Access Limited, Joseph Lee
4+
# This file is covered by the GNU General Public License.
5+
# See the file COPYING for more details.
66

77
from comtypes import COMError
88
import config

source/_UIAHandler.py

+23-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#_UIAHandler.py
22
#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
44
#This file is covered by the GNU General Public License.
55
#See the file COPYING for more details.
66

@@ -144,16 +144,20 @@
144144
UIA_SelectionItem_ElementAddedToSelectionEventId:"stateChange",
145145
UIA_SelectionItem_ElementRemovedFromSelectionEventId:"stateChange",
146146
#UIA_MenuModeEndEventId:"menuModeEnd",
147-
#UIA_Text_TextSelectionChangedEventId:"caret",
148147
UIA_ToolTipOpenedEventId:"UIA_toolTipOpened",
149148
#UIA_AsyncContentLoadedEventId:"documentLoadComplete",
150149
#UIA_ToolTipClosedEventId:"hide",
151150
UIA_Window_WindowOpenedEventId:"UIA_window_windowOpen",
152151
UIA_SystemAlertEventId:"UIA_systemAlert",
153152
}
154153

154+
autoSelectDetectionAvailable = False
155155
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
157161

158162
ignoreWinEventsMap = {
159163
UIA_AutomationPropertyChangedEventId: list(UIAPropertyIdsToNVDAEventNames.keys()),
@@ -273,20 +277,25 @@ def IUIAutomationEventHandler_HandleAutomationEvent(self,sender,eventID):
273277
NVDAEventName=UIAEventIdsToNVDAEventNames.get(eventID,None)
274278
if not NVDAEventName:
275279
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):
277288
return
278289
window=self.getNearestWindowHandle(sender)
279290
if window and not eventHandler.shouldAcceptEvent(NVDAEventName,windowHandle=window):
280291
return
281-
import NVDAObjects.UIA
282292
obj=NVDAObjects.UIA.UIA(UIAElement=sender)
283293
if (
284294
not obj
285295
or (NVDAEventName=="gainFocus" and not obj.shouldAllowUIAFocusEvent)
286296
or (NVDAEventName=="liveRegionChange" and not obj._shouldAllowUIALiveRegionChangeEvent)
287297
):
288298
return
289-
focus=api.getFocusObject()
290299
if obj==focus:
291300
obj=focus
292301
eventHandler.queueEvent(NVDAEventName,obj)
@@ -328,16 +337,21 @@ def IUIAutomationPropertyChangedEventHandler_HandlePropertyChangedEvent(self,sen
328337
NVDAEventName=UIAPropertyIdsToNVDAEventNames.get(propertyId,None)
329338
if not NVDAEventName:
330339
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):
332348
return
333349
window=self.getNearestWindowHandle(sender)
334350
if window and not eventHandler.shouldAcceptEvent(NVDAEventName,windowHandle=window):
335351
return
336-
import NVDAObjects.UIA
337352
obj=NVDAObjects.UIA.UIA(UIAElement=sender)
338353
if not obj:
339354
return
340-
focus=api.getFocusObject()
341355
if obj==focus:
342356
obj=focus
343357
eventHandler.queueEvent(NVDAEventName,obj)

0 commit comments

Comments
 (0)