Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use auto select detection for UIA when listening for TextChanged and TextSelectionChanged events #9660

Merged
merged 12 commits into from
Sep 10, 2019
Merged
16 changes: 13 additions & 3 deletions source/NVDAObjects/UIA/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,14 @@
from UIAUtils import *
from NVDAObjects.window import Window
from NVDAObjects import NVDAObjectTextInfo, InvalidNVDAObject
from NVDAObjects.behaviors import ProgressBar, EditableTextWithoutAutoSelectDetection, Dialog, Notification, EditableTextWithSuggestions
from NVDAObjects.behaviors import (
ProgressBar,
EditableTextWithoutAutoSelectDetection,
EditableTextWithAutoSelectDetection,
Dialog,
Notification,
EditableTextWithSuggestions
)
import braille
from locationHelper import RectLTWH
import ui
Expand Down Expand Up @@ -868,7 +875,10 @@ def findOverlayClasses(self,clsList):
clsList.append(winConsoleUIA)
# Add editableText support if UIA supports a text pattern
if self.TextInfo==UIATextInfo:
clsList.append(EditableTextWithoutAutoSelectDetection)
if UIAHandler.autoSelectDetectionAvailable:
clsList.append(EditableTextWithAutoSelectDetection)
else:
clsList.append(EditableTextWithoutAutoSelectDetection)

clsList.append(UIA)

Expand Down Expand Up @@ -1452,7 +1462,7 @@ def event_UIA_elementSelected(self):
self.event_stateChange()

def event_valueChange(self):
if isinstance(self, EditableTextWithoutAutoSelectDetection):
if self.TextInfo==UIATextInfo:
return
return super(UIA, self).event_valueChange()

Expand Down
11 changes: 7 additions & 4 deletions source/NVDAObjects/window/winword.py
Original file line number Diff line number Diff line change
Expand Up @@ -1431,6 +1431,13 @@ def script_changeLineSpacing(self,gesture):
# Translators: a message when switching to 1.5 line spaceing in Microsoft word
ui.message(_("1.5 line spacing"))

def initOverlayClass(self):
if isinstance(self, EditableTextWithoutAutoSelectDetection):
self.bindGesture("kb:alt+shift+home", "caret_changeSelection")
self.bindGesture("kb:alt+shift+end", "caret_changeSelection")
self.bindGesture("kb:alt+shift+pageUp", "caret_changeSelection",)
self.bindGesture("kb:alt+shift+pageDown", "caret_changeSelection",)

__gestures = {
"kb:control+[":"increaseDecreaseFontSize",
"kb:control+]":"increaseDecreaseFontSize",
Expand Down Expand Up @@ -1458,10 +1465,6 @@ def script_changeLineSpacing(self,gesture):
"kb:control+5":"changeLineSpacing",
"kb:tab": "tab",
"kb:shift+tab": "tab",
"kb:alt+shift+home":"caret_changeSelection",
"kb:alt+shift+end":"caret_changeSelection",
"kb:alt+shift+pageUp":"caret_changeSelection",
"kb:alt+shift+pageDown":"caret_changeSelection",
"kb:control+pageUp": "caret_moveByLine",
"kb:control+pageDown": "caret_moveByLine",
}
Expand Down
10 changes: 7 additions & 3 deletions source/_UIAHandler.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#_UIAHandler.py
#A part of NonVisual Desktop Access (NVDA)
#Copyright (C) 2011-2019 NV Access Limited, Joseph Lee, Babbage B.V.
#Copyright (C) 2011-2019 NV Access Limited, Joseph Lee, Babbage B.V., Leonard de Ruijter
#This file is covered by the GNU General Public License.
#See the file COPYING for more details.

Expand Down Expand Up @@ -142,16 +142,20 @@
UIA_SelectionItem_ElementAddedToSelectionEventId:"stateChange",
UIA_SelectionItem_ElementRemovedFromSelectionEventId:"stateChange",
#UIA_MenuModeEndEventId:"menuModeEnd",
#UIA_Text_TextSelectionChangedEventId:"caret",
UIA_ToolTipOpenedEventId:"UIA_toolTipOpened",
#UIA_AsyncContentLoadedEventId:"documentLoadComplete",
#UIA_ToolTipClosedEventId:"hide",
UIA_Window_WindowOpenedEventId:"UIA_window_windowOpen",
UIA_SystemAlertEventId:"UIA_systemAlert",
}

autoSelectDetectionAvailable = False
if winVersion.isAtLeastWin10():
UIAEventIdsToNVDAEventNames[UIA_Text_TextChangedEventId] = "textChange"
UIAEventIdsToNVDAEventNames.update({
UIA_Text_TextChangedEventId:"textChange",
UIA_Text_TextSelectionChangedEventId:"caret",
})
autoSelectDetectionAvailable = True

ignoreWinEventsMap = {
UIA_AutomationPropertyChangedEventId: list(UIAPropertyIdsToNVDAEventNames.keys()),
Expand Down