Skip to content

Commit 855139b

Browse files
authored
Merge 471c27f into 1af8775
2 parents 1af8775 + 471c27f commit 855139b

File tree

4 files changed

+47
-25
lines changed

4 files changed

+47
-25
lines changed

source/NVDAObjects/UIA/__init__.py

Lines changed: 14 additions & 3 deletions
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

Lines changed: 7 additions & 4 deletions
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

Lines changed: 0 additions & 5 deletions
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

Lines changed: 26 additions & 13 deletions
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) 2011-2019 NV Access Limited, Joseph Lee, Babbage B.V.
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) 2011-2019 NV Access Limited, Joseph Lee, Babbage B.V., Leonard de Ruijter
4+
# This file is covered by the GNU General Public License.
5+
# See the file COPYING for more details.
66

77
from ctypes import *
88
from ctypes.wintypes import *
@@ -144,16 +144,19 @@
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+
autoSelectDetectionAvailable = True
157160

158161
ignoreWinEventsMap = {
159162
UIA_AutomationPropertyChangedEventId: list(UIAPropertyIdsToNVDAEventNames.keys()),
@@ -273,20 +276,25 @@ def IUIAutomationEventHandler_HandleAutomationEvent(self,sender,eventID):
273276
NVDAEventName=UIAEventIdsToNVDAEventNames.get(eventID,None)
274277
if not NVDAEventName:
275278
return
276-
if not self.isNativeUIAElement(sender):
279+
focus = api.getFocusObject()
280+
import NVDAObjects.UIA
281+
if (
282+
isinstance(focus, NVDAObjects.UIA.UIA)
283+
and self.clientObject.compareElements(focus.UIAElement, sender)
284+
):
285+
pass
286+
elif not self.isNativeUIAElement(sender):
277287
return
278288
window=self.getNearestWindowHandle(sender)
279289
if window and not eventHandler.shouldAcceptEvent(NVDAEventName,windowHandle=window):
280290
return
281-
import NVDAObjects.UIA
282291
obj=NVDAObjects.UIA.UIA(UIAElement=sender)
283292
if (
284293
not obj
285294
or (NVDAEventName=="gainFocus" and not obj.shouldAllowUIAFocusEvent)
286295
or (NVDAEventName=="liveRegionChange" and not obj._shouldAllowUIALiveRegionChangeEvent)
287296
):
288297
return
289-
focus=api.getFocusObject()
290298
if obj==focus:
291299
obj=focus
292300
eventHandler.queueEvent(NVDAEventName,obj)
@@ -328,16 +336,21 @@ def IUIAutomationPropertyChangedEventHandler_HandlePropertyChangedEvent(self,sen
328336
NVDAEventName=UIAPropertyIdsToNVDAEventNames.get(propertyId,None)
329337
if not NVDAEventName:
330338
return
331-
if not self.isNativeUIAElement(sender):
339+
focus = api.getFocusObject()
340+
import NVDAObjects.UIA
341+
if (
342+
isinstance(focus, NVDAObjects.UIA.UIA)
343+
and self.clientObject.compareElements(focus.UIAElement, sender)
344+
):
345+
pass
346+
elif not self.isNativeUIAElement(sender):
332347
return
333348
window=self.getNearestWindowHandle(sender)
334349
if window and not eventHandler.shouldAcceptEvent(NVDAEventName,windowHandle=window):
335350
return
336-
import NVDAObjects.UIA
337351
obj=NVDAObjects.UIA.UIA(UIAElement=sender)
338352
if not obj:
339353
return
340-
focus=api.getFocusObject()
341354
if obj==focus:
342355
obj=focus
343356
eventHandler.queueEvent(NVDAEventName,obj)

0 commit comments

Comments
 (0)