From 2300881c89930fa1936f77ba5848d9ec2a730031 Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Tue, 16 Aug 2016 20:20:25 -0700 Subject: [PATCH 01/26] UIA objects: introduce a global suggestion list item class for Windows 10. re #6241 Windows 10 uses suggestions list for vairous things, including Start menu suggestions, Store recommendations, Settings app and others. Thus introduce NVDAObjects.UIA.SuggestionListItem, which derives its power from searchui.py version (searchui.py version is gone). --- source/NVDAObjects/UIA/__init__.py | 19 +++++++++++++++++++ source/appModules/searchui.py | 18 ++---------------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/source/NVDAObjects/UIA/__init__.py b/source/NVDAObjects/UIA/__init__.py index 1a05fb467ee..cd24ee9070b 100644 --- a/source/NVDAObjects/UIA/__init__.py +++ b/source/NVDAObjects/UIA/__init__.py @@ -600,6 +600,12 @@ def findOverlayClasses(self,clsList): # #5942: In recent Windows 10 Redstone builds (14332 and later), Microsoft rewrote various dialog code including that of User Account Control. if self.UIAIsWindowElement and UIAClassName in ("#32770","NUIDialog", "Credential Dialog Xaml Host"): clsList.append(Dialog) + # 6241: Try detecting all possible suggestions containers scattered throughout Windows 10. + try: + if self.parent.UIAElement.cachedAutomationId.lower()=="suggestionslist": + clsList.append(SuggestionListItem) + except AttributeError: + pass clsList.append(UIA) @@ -1240,3 +1246,16 @@ def event_nameChange(self): def event_stateChange(self): return +class SuggestionListItem(UIA): + """Windows 10 uses suggestions lists for various things, including Start menu suggestions, Store, Settings app and so on. + """ + + role=controlTypes.ROLE_LISTITEM + + def event_UIA_elementSelected(self): + focusControllerFor=api.getFocusObject().controllerFor + if len(focusControllerFor)>0 and focusControllerFor[0].appModule is self.appModule and self.name: + speech.cancelSpeech() + api.setNavigatorObject(self) + self.reportFocus() + diff --git a/source/appModules/searchui.py b/source/appModules/searchui.py index 159ccf3f066..9907f240828 100644 --- a/source/appModules/searchui.py +++ b/source/appModules/searchui.py @@ -1,5 +1,5 @@ #A part of NonVisual Desktop Access (NVDA) -#Copyright (C) 2015 NV Access Limited +#Copyright (C) 2015-2016 NV Access Limited #This file is covered by the GNU General Public License. #See the file COPYING for more details. @@ -11,24 +11,10 @@ from NVDAObjects.UIA.edge import EdgeList from NVDAObjects.IAccessible import IAccessible, ContentGenericClient -# Windows 10 Search UI suggestion list item -class SuggestionListItem(UIA): - - role=controlTypes.ROLE_LISTITEM - - def event_UIA_elementSelected(self): - focusControllerFor=api.getFocusObject().controllerFor - if len(focusControllerFor)>0 and focusControllerFor[0].appModule is self.appModule and self.name: - speech.cancelSpeech() - api.setNavigatorObject(self) - self.reportFocus() - class AppModule(appModuleHandler.AppModule): def chooseNVDAObjectOverlayClasses(self,obj,clsList): - if isinstance(obj,UIA) and isinstance(obj.parent,EdgeList): - clsList.insert(0,SuggestionListItem) - elif isinstance(obj,IAccessible): + if isinstance(obj,IAccessible): try: # #5288: Never use ContentGenericClient, as this uses displayModel # which will freeze if the process is suspended. From 8cb96b1f9dc6d3aa2ec7866af199ec1dafeb316b Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Wed, 17 Aug 2016 17:01:54 -0700 Subject: [PATCH 02/26] SearchUI: remove unneeded imports --- source/appModules/searchui.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/source/appModules/searchui.py b/source/appModules/searchui.py index 9907f240828..383f0f4dfa5 100644 --- a/source/appModules/searchui.py +++ b/source/appModules/searchui.py @@ -4,11 +4,6 @@ #See the file COPYING for more details. import appModuleHandler -import controlTypes -import api -import speech -from NVDAObjects.UIA import UIA -from NVDAObjects.UIA.edge import EdgeList from NVDAObjects.IAccessible import IAccessible, ContentGenericClient class AppModule(appModuleHandler.AppModule): From fb57f8f11d0ead13a16f23b56f159b21063cd631 Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Tue, 9 Aug 2016 02:16:35 -0700 Subject: [PATCH 03/26] UIA handler: add proper copyright header (based on Git log archive) --- source/UIAHandler.py | 6 ++++++ source/_UIAHandler.py | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/source/UIAHandler.py b/source/UIAHandler.py index e4c7cb92f83..939eb81db55 100644 --- a/source/UIAHandler.py +++ b/source/UIAHandler.py @@ -1,3 +1,9 @@ +#UIAHandler.py +#A part of NonVisual Desktop Access (NVDA) +#Copyright (C) 2008-2016 NV Access Limited +#This file is covered by the GNU General Public License. +#See the file COPYING for more details. + import winVersion import comtypes import config diff --git a/source/_UIAHandler.py b/source/_UIAHandler.py index bcb8eb95f53..5767c35bee1 100644 --- a/source/_UIAHandler.py +++ b/source/_UIAHandler.py @@ -1,3 +1,9 @@ +#_UIAHandler.py +#A part of NonVisual Desktop Access (NVDA) +#Copyright (C) 2011-2016 NV Access Limited +#This file is covered by the GNU General Public License. +#See the file COPYING for more details. + from ctypes import * from ctypes.wintypes import * import comtypes.client From 41d729a64ebec9a1b03e07cacd176acf7a8251af Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Thu, 18 Aug 2016 09:34:01 -0700 Subject: [PATCH 04/26] UIA: add support for Controller For property. re #6241 Controller For property is used by an element to let another element depend on values given by the source element, useful if suggestions should be listed for a search field among other possibilities. For now, Controller For property has been added to property to event names map in UIA Handler. A UIA object that handles this event (a search box) is next. --- source/_UIAHandler.py | 1 + 1 file changed, 1 insertion(+) diff --git a/source/_UIAHandler.py b/source/_UIAHandler.py index 5767c35bee1..300c9c7892c 100644 --- a/source/_UIAHandler.py +++ b/source/_UIAHandler.py @@ -123,6 +123,7 @@ UIA_IsEnabledPropertyId:"stateChange", UIA_ValueValuePropertyId:"valueChange", UIA_RangeValueValuePropertyId:"valueChange", + UIA_ControllerForPropertyId:"UIA_controllerFor" } UIAEventIdsToNVDAEventNames={ From 745a53885199b54993fa0f96166d69fd385e0c96 Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Thu, 18 Aug 2016 09:55:27 -0700 Subject: [PATCH 05/26] Revert "UIA: add support for Controller For property. re #6241" This reverts commit a3b1ce57408fc571b1f92aa38901c243a8171fad. --- source/_UIAHandler.py | 1 - 1 file changed, 1 deletion(-) diff --git a/source/_UIAHandler.py b/source/_UIAHandler.py index 300c9c7892c..5767c35bee1 100644 --- a/source/_UIAHandler.py +++ b/source/_UIAHandler.py @@ -123,7 +123,6 @@ UIA_IsEnabledPropertyId:"stateChange", UIA_ValueValuePropertyId:"valueChange", UIA_RangeValueValuePropertyId:"valueChange", - UIA_ControllerForPropertyId:"UIA_controllerFor" } UIAEventIdsToNVDAEventNames={ From 5eb19786eab1c270ad371555a64b842c70b5ad81 Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Thu, 18 Aug 2016 09:58:01 -0700 Subject: [PATCH 06/26] UIA: add support for Controller For property. re #6241 Controller For property is used by an element to let another element depend on values given by the source element, useful if suggestions should be listed for a search field among other possibilities. For now, Controller For property has been added to property to event names map in UIA Handler. A UIA object that handles this event (a search box) is next. --- source/_UIAHandler.py | 1 + 1 file changed, 1 insertion(+) diff --git a/source/_UIAHandler.py b/source/_UIAHandler.py index 5767c35bee1..073e83259a8 100644 --- a/source/_UIAHandler.py +++ b/source/_UIAHandler.py @@ -123,6 +123,7 @@ UIA_IsEnabledPropertyId:"stateChange", UIA_ValueValuePropertyId:"valueChange", UIA_RangeValueValuePropertyId:"valueChange", + UIA_ControllerForPropertyId:"UIA_controllerFor", } UIAEventIdsToNVDAEventNames={ From 665bdbd3ccb8ffebe7a511b250e3661f2f1f2a71 Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Thu, 18 Aug 2016 10:19:02 -0700 Subject: [PATCH 07/26] NVDAObjects.UIA: introduce Search Field that'll handle controller for and announce appearance of suggestions. re #6241 Coming from Windows 10 App Essentials add-on: a Search Field is now available that'll detect controller for property event and announce either 'suggestions' or 'suggestions closed' if suggestions appear or disappear, respectively. This takes care of both Start Menu and other fields in Windows 10 (works best in Anniversary Update and later). --- source/NVDAObjects/UIA/__init__.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/source/NVDAObjects/UIA/__init__.py b/source/NVDAObjects/UIA/__init__.py index cd24ee9070b..deab6910ede 100644 --- a/source/NVDAObjects/UIA/__init__.py +++ b/source/NVDAObjects/UIA/__init__.py @@ -24,6 +24,7 @@ from NVDAObjects import NVDAObjectTextInfo, InvalidNVDAObject from NVDAObjects.behaviors import ProgressBar, EditableTextWithoutAutoSelectDetection, Dialog, Notification import braille +import ui class UIATextInfo(textInfos.TextInfo): @@ -600,7 +601,9 @@ def findOverlayClasses(self,clsList): # #5942: In recent Windows 10 Redstone builds (14332 and later), Microsoft rewrote various dialog code including that of User Account Control. if self.UIAIsWindowElement and UIAClassName in ("#32770","NUIDialog", "Credential Dialog Xaml Host"): clsList.append(Dialog) - # 6241: Try detecting all possible suggestions containers scattered throughout Windows 10. + # 6241: Try detecting all possible suggestions containers and search fields scattered throughout Windows 10. + if self.UIAElement.cachedAutomationID in ("TextBox", "SearchTextBox"): + clsList.append(SearchField) try: if self.parent.UIAElement.cachedAutomationId.lower()=="suggestionslist": clsList.append(SuggestionListItem) @@ -1246,6 +1249,22 @@ def event_nameChange(self): def event_stateChange(self): return +class SearchField(UIA): + """An edit field that presents suggestions based on search term. + """ + + def event_UIA_controllerFor(self): + # Only useful if suggestions appear and disappear. + focus = api.getFocusObject() + if len(self.controllerFor)>0: + # Translators: Announced when suggestions appear when search term is entered in various search fields in Windows 10. + ui.message(_("Suggestions")) + else: + # Translators: Announced when suggestions disappear when search term is entered in various search fields in Windows 10. + ui.message(_("Suggestions closed")) + + + class SuggestionListItem(UIA): """Windows 10 uses suggestions lists for various things, including Start menu suggestions, Store, Settings app and so on. """ From 09a1471f4957cf37fc18c30f1714353617514de4 Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Thu, 27 Oct 2016 14:50:37 -0700 Subject: [PATCH 08/26] Search Field: check if search field is focused before asking for controller for object. re #6241 Review from Mick Curran (NV Access): Do not waste a function call for fetching focused element. Besides, make sure to check if the focused control is the search field before proceeding to announce appearance of suggestions. --- source/NVDAObjects/UIA/__init__.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/source/NVDAObjects/UIA/__init__.py b/source/NVDAObjects/UIA/__init__.py index deab6910ede..42312721b95 100644 --- a/source/NVDAObjects/UIA/__init__.py +++ b/source/NVDAObjects/UIA/__init__.py @@ -1255,8 +1255,7 @@ class SearchField(UIA): def event_UIA_controllerFor(self): # Only useful if suggestions appear and disappear. - focus = api.getFocusObject() - if len(self.controllerFor)>0: + if self == api.getFocusObject() and len(self.controllerFor)>0: # Translators: Announced when suggestions appear when search term is entered in various search fields in Windows 10. ui.message(_("Suggestions")) else: @@ -1264,7 +1263,6 @@ def event_UIA_controllerFor(self): ui.message(_("Suggestions closed")) - class SuggestionListItem(UIA): """Windows 10 uses suggestions lists for various things, including Start menu suggestions, Store, Settings app and so on. """ From a3d6af0f0a7f8d0f05a0ec101247da10a19e3041 Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Tue, 17 Jan 2017 20:43:11 -0800 Subject: [PATCH 09/26] Update copyright years, add a docstring to UIA objects (__init__). --- source/NVDAObjects/UIA/__init__.py | 4 +++- source/_UIAHandler.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/source/NVDAObjects/UIA/__init__.py b/source/NVDAObjects/UIA/__init__.py index 42312721b95..a4166cf5b58 100644 --- a/source/NVDAObjects/UIA/__init__.py +++ b/source/NVDAObjects/UIA/__init__.py @@ -2,7 +2,9 @@ #A part of NonVisual Desktop Access (NVDA) #This file is covered by the GNU General Public License. #See the file COPYING for more details. -#Copyright (C) 2009-2016 NV Access Limited, Joseph Lee, Mohammad Suliman +#Copyright (C) 2009-2017 NV Access Limited, Joseph Lee, Mohammad Suliman + +"""Support for UI Automation (UIA) controls.""" from ctypes import byref from ctypes.wintypes import POINT, RECT diff --git a/source/_UIAHandler.py b/source/_UIAHandler.py index 073e83259a8..863760ddd90 100644 --- a/source/_UIAHandler.py +++ b/source/_UIAHandler.py @@ -1,6 +1,6 @@ #_UIAHandler.py #A part of NonVisual Desktop Access (NVDA) -#Copyright (C) 2011-2016 NV Access Limited +#Copyright (C) 2011-2017 NV Access Limited, Joseph Lee #This file is covered by the GNU General Public License. #See the file COPYING for more details. From 0d1f5af2730ca13474c7542610b770ee85e36099 Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Tue, 17 Jan 2017 21:08:42 -0800 Subject: [PATCH 10/26] Suggestion: a new behavior to allow NVDA to detect and announce suggestions. re #6241. Reviewed by Mick Curran (NV Access): announcement of search suggestion is something that NVDA should handle for other API's, such as suggestions in Firefox address bar, search suggestions in universal apps and so on. A new behavior named 'Suggestion' has been added that allows subclasses to provide custom routines when suggestions appear and disappear. This is handled by event_suggestionOpened and event_suggestionClosed, and by default NVDA will speak and braille this event. --- source/NVDAObjects/behaviors.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/source/NVDAObjects/behaviors.py b/source/NVDAObjects/behaviors.py index 78532eb0adc..39bbb000a5d 100755 --- a/source/NVDAObjects/behaviors.py +++ b/source/NVDAObjects/behaviors.py @@ -3,9 +3,10 @@ #A part of NonVisual Desktop Access (NVDA) #This file is covered by the GNU General Public License. #See the file COPYING for more details. -#Copyright (C) 2006-2013 NV Access Limited, Peter Vágner +#Copyright (C) 2006-2017 NV Access Limited, Peter Vágner, Joseph Lee """Mix-in classes which provide common behaviour for particular types of controls across different APIs. +Behaviors described in this mix-in include providing table navigation commands for certain table rows, terminal input and output support, announcing notifications and suggestion items and so on. """ import os @@ -633,3 +634,26 @@ def event_alert(self): braille.handler.message(braille.getBrailleTextForProperties(name=self.name, role=self.role)) event_show = event_alert + +class Suggestion(NVDAObject): + """Allows NvDA to announce appearance/disappearance of suggestions. + This is used in various places, including Windows 10 search edit fields and others. + Subclasses should provide L{event_suggestionsOpened} and can optionally override L{event_suggestionsClosed}. + These events are fired when suggestions appear and disappear, respectively. + """ + + def event_suggestionsOpened(self): + """Called when suggestions appear in response to users entering search terms. + Subclasses should provide custom implementations if possible. + By default, NVDA will announce appearance of suggestions using speech and braille. + """ + # Translators: Announced when suggestions appear when search term is entered in various search fields such as Start search box in Windows 10. + ui.message(_("Suggestions")) + + def event_suggestionsClosed(self): + """Called when suggestions list or container is closed. + Subclasses should provide custom implementations if possible. + By default NVDA will announce this via speech and braille. + """ + # Translators: Announced when suggestions disappear when search term is entered in various search fields such as Start search box in Windows 10. + ui.message(_("Suggestions closed")) From e04e7af9a6b38c4c811ae0a00241d168fe2a2ce7 Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Tue, 17 Jan 2017 21:38:13 -0800 Subject: [PATCH 11/26] UIA objects/Search field: use the new NVDAObjects.behaviors.Suggestion to announce suggestion appearance. re #6241. Reviewed by Mick Curran (NV Access): Based on the new Suggestion behavior mix-in, it is now possible for various objects to provide custom routines to let users know the appearance of suggestions. Thus UIA/Search Field is the first object to use this routine. --- source/NVDAObjects/UIA/__init__.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/source/NVDAObjects/UIA/__init__.py b/source/NVDAObjects/UIA/__init__.py index a4166cf5b58..fa75583fbab 100644 --- a/source/NVDAObjects/UIA/__init__.py +++ b/source/NVDAObjects/UIA/__init__.py @@ -24,9 +24,8 @@ from UIAUtils import * from NVDAObjects.window import Window from NVDAObjects import NVDAObjectTextInfo, InvalidNVDAObject -from NVDAObjects.behaviors import ProgressBar, EditableTextWithoutAutoSelectDetection, Dialog, Notification +from NVDAObjects.behaviors import ProgressBar, EditableTextWithoutAutoSelectDetection, Dialog, Notification, Suggestion import braille -import ui class UIATextInfo(textInfos.TextInfo): @@ -1251,18 +1250,16 @@ def event_nameChange(self): def event_stateChange(self): return -class SearchField(UIA): +class SearchField(Suggestion, UIA): """An edit field that presents suggestions based on search term. """ def event_UIA_controllerFor(self): # Only useful if suggestions appear and disappear. if self == api.getFocusObject() and len(self.controllerFor)>0: - # Translators: Announced when suggestions appear when search term is entered in various search fields in Windows 10. - ui.message(_("Suggestions")) + self.event_suggestionsOpened() else: - # Translators: Announced when suggestions disappear when search term is entered in various search fields in Windows 10. - ui.message(_("Suggestions closed")) + self.event_suggestionsClosed() class SuggestionListItem(UIA): @@ -1277,4 +1274,3 @@ def event_UIA_elementSelected(self): speech.cancelSpeech() api.setNavigatorObject(self) self.reportFocus() - From 1904711d07c80e318f4a12a82bd82bbca019097d Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Tue, 17 Jan 2017 23:07:11 -0800 Subject: [PATCH 12/26] UIA objects/suggestions list: use raw UIA base tree walker to obtain suggestion list (parent). re #6241. Reviewed by Mick Curran (NV Access): it is better to use raw UIA for obtaining parent element. However, one must be careful to catch COM and value errors (COM because the element might not be there, and value because NULL pointer access is logged). The raw UIA method was also recommended by Derek Riemer. --- source/NVDAObjects/UIA/__init__.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/source/NVDAObjects/UIA/__init__.py b/source/NVDAObjects/UIA/__init__.py index fa75583fbab..683ea176541 100644 --- a/source/NVDAObjects/UIA/__init__.py +++ b/source/NVDAObjects/UIA/__init__.py @@ -602,13 +602,19 @@ def findOverlayClasses(self,clsList): # #5942: In recent Windows 10 Redstone builds (14332 and later), Microsoft rewrote various dialog code including that of User Account Control. if self.UIAIsWindowElement and UIAClassName in ("#32770","NUIDialog", "Credential Dialog Xaml Host"): clsList.append(Dialog) - # 6241: Try detecting all possible suggestions containers and search fields scattered throughout Windows 10. + # #6241: Try detecting all possible suggestions containers and search fields scattered throughout Windows 10. if self.UIAElement.cachedAutomationID in ("TextBox", "SearchTextBox"): clsList.append(SearchField) try: - if self.parent.UIAElement.cachedAutomationId.lower()=="suggestionslist": + # #6241: Raw UIA base tree walker is better than simply looking at self.parent when locating suggestion list items. + parentElement=UIAHandler.handler.baseTreeWalker.GetParentElementBuildCache(self.UIAElement,UIAHandler.handler.baseCacheRequest) + except COMError: + pass + try: + # Sometimes, fetching parent (list control) via base tree walker fails, especially when dealing with suggestions in Windows10 Start menu. + if parentElement.cachedAutomationId.lower()=="suggestionslist": clsList.append(SuggestionListItem) - except AttributeError: + except ValueError: pass clsList.append(UIA) From b3c087405504adf3668f559ae9b3a02ac65c0c63 Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Tue, 17 Jan 2017 23:09:08 -0800 Subject: [PATCH 13/26] UIA objects: updated comments, removed reference to Redstone. --- source/NVDAObjects/UIA/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/NVDAObjects/UIA/__init__.py b/source/NVDAObjects/UIA/__init__.py index 683ea176541..733c48e81f9 100644 --- a/source/NVDAObjects/UIA/__init__.py +++ b/source/NVDAObjects/UIA/__init__.py @@ -599,7 +599,7 @@ def findOverlayClasses(self,clsList): pass elif UIAControlType==UIAHandler.UIA_ListItemControlTypeId: clsList.append(ListItem) - # #5942: In recent Windows 10 Redstone builds (14332 and later), Microsoft rewrote various dialog code including that of User Account Control. + # #5942: In Windows 10 build 14332 and later, Microsoft rewrote various dialog code including that of User Account Control. if self.UIAIsWindowElement and UIAClassName in ("#32770","NUIDialog", "Credential Dialog Xaml Host"): clsList.append(Dialog) # #6241: Try detecting all possible suggestions containers and search fields scattered throughout Windows 10. @@ -1239,7 +1239,7 @@ class Toast_win8(Notification, UIA): class Toast_win10(Notification, UIA): - # #6096: Windows 10 Redstone build 14366 and later does not fire tooltip event when toasts appear. + # #6096: Windows 10 build 14366 and later does not fire tooltip event when toasts appear. if sys.getwindowsversion().build > 10586: event_UIA_window_windowOpen=Notification.event_alert else: From e253c57c553c4581bd1bc32287ac1e5da29ac660 Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Wed, 18 Jan 2017 12:26:30 -0800 Subject: [PATCH 14/26] UIA objects/Search field: don't allow suggestions detection be announced in Windows 10 Start menu for consistency with earlier versions of Windows. re #6241. iN Windows 10 Start menu, suggestions are announced automaticlaly, so no need to provide suggestion announcements. --- source/NVDAObjects/UIA/__init__.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/source/NVDAObjects/UIA/__init__.py b/source/NVDAObjects/UIA/__init__.py index 733c48e81f9..2a66efb7725 100644 --- a/source/NVDAObjects/UIA/__init__.py +++ b/source/NVDAObjects/UIA/__init__.py @@ -603,14 +603,16 @@ def findOverlayClasses(self,clsList): if self.UIAIsWindowElement and UIAClassName in ("#32770","NUIDialog", "Credential Dialog Xaml Host"): clsList.append(Dialog) # #6241: Try detecting all possible suggestions containers and search fields scattered throughout Windows 10. - if self.UIAElement.cachedAutomationID in ("TextBox", "SearchTextBox"): + # But don't let suggestions list appearance be announced in Windows 10 Start menu for consistent experience with earlier Windows versions. + if self.UIAElement.cachedAutomationID == "TextBox": clsList.append(SearchField) try: - # #6241: Raw UIA base tree walker is better than simply looking at self.parent when locating suggestion list items. - parentElement=UIAHandler.handler.baseTreeWalker.GetParentElementBuildCache(self.UIAElement,UIAHandler.handler.baseCacheRequest) - except COMError: - pass - try: + # Nested block here in order to catch value error when attempting to access automation ID for invalid elements. + try: + # #6241: Raw UIA base tree walker is better than simply looking at self.parent when locating suggestion list items. + parentElement=UIAHandler.handler.baseTreeWalker.GetParentElementBuildCache(self.UIAElement,UIAHandler.handler.baseCacheRequest) + except COMError: + pass # Sometimes, fetching parent (list control) via base tree walker fails, especially when dealing with suggestions in Windows10 Start menu. if parentElement.cachedAutomationId.lower()=="suggestionslist": clsList.append(SuggestionListItem) From f51fa695e01d7e1df8d769b67986d8933dece27b Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Wed, 18 Jan 2017 12:43:11 -0800 Subject: [PATCH 15/26] NVDAObjects/behaviors: rename 'Suggestion' to 'EditableTextWithSuggestions' so the behavior can be better described. re #6241. If one inherits from 'Suggestion', the overall impression would be that the field is only going to display suggestions nad nothing else. Many suggestions are shown when text is entered, thus it is better to say 'EditableTextWithSuggestions' to better reflect what the behavior actually does. Also, a sound will be played to let users know the appearance of suggestions. (default vlaue). --- source/NVDAObjects/UIA/__init__.py | 6 +++--- source/NVDAObjects/behaviors.py | 31 +++++++++++++++++++++--------- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/source/NVDAObjects/UIA/__init__.py b/source/NVDAObjects/UIA/__init__.py index 2a66efb7725..58bae62916b 100644 --- a/source/NVDAObjects/UIA/__init__.py +++ b/source/NVDAObjects/UIA/__init__.py @@ -24,7 +24,7 @@ from UIAUtils import * from NVDAObjects.window import Window from NVDAObjects import NVDAObjectTextInfo, InvalidNVDAObject -from NVDAObjects.behaviors import ProgressBar, EditableTextWithoutAutoSelectDetection, Dialog, Notification, Suggestion +from NVDAObjects.behaviors import ProgressBar, EditableTextWithoutAutoSelectDetection, Dialog, Notification, EditableTextWithSuggestions import braille class UIATextInfo(textInfos.TextInfo): @@ -1258,8 +1258,8 @@ def event_nameChange(self): def event_stateChange(self): return -class SearchField(Suggestion, UIA): - """An edit field that presents suggestions based on search term. +class SearchField(EditableTextWithSuggestions, UIA): + """An edit field that presents suggestions based on a search term. """ def event_UIA_controllerFor(self): diff --git a/source/NVDAObjects/behaviors.py b/source/NVDAObjects/behaviors.py index 39bbb000a5d..e191c2ba850 100755 --- a/source/NVDAObjects/behaviors.py +++ b/source/NVDAObjects/behaviors.py @@ -27,6 +27,7 @@ import api import ui import braille +import nvwave class ProgressBar(NVDAObject): @@ -635,25 +636,37 @@ def event_alert(self): event_show = event_alert -class Suggestion(NVDAObject): - """Allows NvDA to announce appearance/disappearance of suggestions. +class EditableTextWithSuggestions(NVDAObject): + """Allows NvDA to announce appearance/disappearance of suggestions as text is entered. This is used in various places, including Windows 10 search edit fields and others. Subclasses should provide L{event_suggestionsOpened} and can optionally override L{event_suggestionsClosed}. These events are fired when suggestions appear and disappear, respectively. """ def event_suggestionsOpened(self): - """Called when suggestions appear in response to users entering search terms. + """Called when suggestions appear when text is entered e.g. search suggestions. Subclasses should provide custom implementations if possible. - By default, NVDA will announce appearance of suggestions using speech and braille. + By default NVDA will announce appearance of suggestions using speech, braille or a sound will be played. """ - # Translators: Announced when suggestions appear when search term is entered in various search fields such as Start search box in Windows 10. - ui.message(_("Suggestions")) + reportAutoSuggestions = config.conf["presentation"]["reportAutoSuggestions"] + if reportAutoSuggestions in ("message", "sound"): + # Translators: Announced when suggestions appear when search term is entered in various search fields such as Start search box in Windows 10. + braille.handler.message(_("Suggestions")) + if reportAutoSuggestions == "message": + speech.speakMessage(_("Suggestions")) + elif reportAutoSuggestions == "sound": + nvwave.playWaveFile(r"waves\suggestionsOpened.wav") def event_suggestionsClosed(self): """Called when suggestions list or container is closed. Subclasses should provide custom implementations if possible. - By default NVDA will announce this via speech and braille. + By default NVDA will announce this via speech, braille or via a sound. """ - # Translators: Announced when suggestions disappear when search term is entered in various search fields such as Start search box in Windows 10. - ui.message(_("Suggestions closed")) + reportAutoSuggestions = config.conf["presentation"]["reportAutoSuggestions"] + if reportAutoSuggestions in ("message", "sound"): + # Translators: Announced when suggestions disappear when search term is entered in various search fields such as Start search box in Windows 10. + braille.handler.message(_("Suggestions closed")) + if reportAutoSuggestions == "message": + speech.speakMessage(_("Suggestions closed")) + elif reportAutoSuggestions == "sound": + nvwave.playWaveFile(r"waves\suggestionsClosed.wav") From 35a639d6045b67acbf991d33ba9dbdbcc7b289d9 Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Wed, 18 Jan 2017 20:00:45 -0800 Subject: [PATCH 16/26] Auto-suggestions: add a combo box in object presentation settings to configure how auto-suggestions should be announced. re #6241 --- source/gui/settingsDialogs.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/source/gui/settingsDialogs.py b/source/gui/settingsDialogs.py index d3a7442fd2c..bc0d21dbb8a 100644 --- a/source/gui/settingsDialogs.py +++ b/source/gui/settingsDialogs.py @@ -887,6 +887,23 @@ class ObjectPresentationDialog(SettingsDialog): ("both", _("Speak and beep")), ) + autoSuggestionsLabels = ( + # Translators: An option for auto-suggestions output in the Object Presentation dialog + # which disables reporting of appearance of suggestions. + # See Report auto-suggestions in the Object Presentation Settings section of the User Guide. + ("off", _("off")), + # Translators: An option for auto-suggestions output in the Object Presentation dialog + # which disables reporting of appearance of suggestions. + # See Report auto-suggestions in the Object Presentation Settings section of the User Guide. + + # which announces appearance of suggestions via speech and braille. + ("message", _("Message")), + # Translators: An option for auto-suggestions output in the Object Presentation dialog + # which reports appearance of suggestions via a sound. + # See Report auto-suggestions in the Object Presentation Settings section of the User Guide. + ("sound", _("Sound")), + ) + def makeSettings(self, settingsSizer): sHelper = guiHelper.BoxSizerHelper(self, sizer=settingsSizer) # Translators: This is the label for a checkbox in the @@ -949,6 +966,16 @@ def makeSettings(self, settingsSizer): self.dynamicContentCheckBox=sHelper.addItem(wx.CheckBox(self,label=dynamicContentText)) self.dynamicContentCheckBox.SetValue(config.conf["presentation"]["reportDynamicContentChanges"]) + # Translators: This is the label for a combobox in the + # object presentation settings dialog. + autoSuggestionsLabelText = _("Report &auto-suggestions:") + autoSuggestionsChoices = [name for setting, name in self.autoSuggestionsLabels] + self.autoSuggestionsList=sHelper.addLabeledControl(autoSuggestionsLabelText, wx.Choice,choices=autoSuggestionsChoices) + for index, (setting, name) in enumerate(self.autoSuggestionsLabels): + if setting == config.conf["presentation"]["reportAutoSuggestions"]: + self.autoSuggestionsList.SetSelection(index) + break + def postInit(self): self.tooltipCheckBox.SetFocus() @@ -962,6 +989,7 @@ def onOk(self,evt): config.conf["presentation"]["progressBarUpdates"]["progressBarOutputMode"]=self.progressLabels[self.progressList.GetSelection()][0] config.conf["presentation"]["progressBarUpdates"]["reportBackgroundProgressBars"]=self.reportBackgroundProgressBarsCheckBox.IsChecked() config.conf["presentation"]["reportDynamicContentChanges"]=self.dynamicContentCheckBox.IsChecked() + config.conf["presentation"]["reportAutoSuggestions"]=self.autoSuggestionsLabels[self.autoSuggestionsList.GetSelection()][0] super(ObjectPresentationDialog, self).onOk(evt) class BrowseModeDialog(SettingsDialog): From f088b1b76c62905c6a52750a84fd50fa254d9cc0 Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Wed, 18 Jan 2017 20:25:15 -0800 Subject: [PATCH 17/26] User guide: document auto-suggestions notification setting. re #6241. In the user guide, an explanatory text has been added to describe what auto-suggestions are. --- source/gui/settingsDialogs.py | 2 +- user_docs/en/userGuide.t2t | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/source/gui/settingsDialogs.py b/source/gui/settingsDialogs.py index bc0d21dbb8a..f318f285f7c 100644 --- a/source/gui/settingsDialogs.py +++ b/source/gui/settingsDialogs.py @@ -968,7 +968,7 @@ def makeSettings(self, settingsSizer): # Translators: This is the label for a combobox in the # object presentation settings dialog. - autoSuggestionsLabelText = _("Report &auto-suggestions:") + autoSuggestionsLabelText = _("&Auto-suggestions notification:") autoSuggestionsChoices = [name for setting, name in self.autoSuggestionsLabels] self.autoSuggestionsList=sHelper.addLabeledControl(autoSuggestionsLabelText, wx.Choice,choices=autoSuggestionsChoices) for index, (setting, name) in enumerate(self.autoSuggestionsLabels): diff --git a/user_docs/en/userGuide.t2t b/user_docs/en/userGuide.t2t index 79017101f80..dc86e290ae3 100644 --- a/user_docs/en/userGuide.t2t +++ b/user_docs/en/userGuide.t2t @@ -1120,6 +1120,19 @@ Key: NVDA+5 Toggles the announcement of new content in particular objects such as terminals and the history control in chat programs. +==== Auto-suggestions notification ==== +This option allows you to configure how NVDA will notify you of appearance of auto-suggestions. +Auto-suggestions are lists of suggested entries based on text entered into certain edit fields and documents. +For example, when you enter text into the search box in Start menu in Windows Vista and later, Windows displays a list of suggestions based on what you typed. +For some edit fields such as search fields in various Windows 10 apps, NVDA can notify you that a list of suggestions has appeared when you type text. +The auto-suggestions list will close once you move away from the edit field, and for some fields, NVDA can notify you of this when this happens. + +The ways in which NVDA can notify you of appearance of auto-suggestions are: +- Off: Appearance of suggestions will not be announced. +- Message: NVDA will speak or braille a message when suggestions appear. +- Sound: NVDA will play a sound when suggestions appear. +- + +++ Input Composition Settings +++ The Input Composition Settings dialog can be found under the Preferences menu. This dialog allows you to control how NVDA reports the input of Asian characters, such as with IME or Text Service input methods. From 7f804073bd2b0991598e6148986ba8f75239d377 Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Wed, 18 Jan 2017 22:22:27 -0800 Subject: [PATCH 18/26] Auto-suggestions: either play a sound or do nothing. re #6241. Comments from Mick Curran and Jamie Teh (NV Access): no need for a separate message option when announcing appearance of auto-suggestions, as the sound cue will let the user of this fact. However, braille users should be notified of this regardless of this flag being turned on (deaf-blind users should be notified of this). User guide and settings dialog: changed the control type and label for auto-suggestions setting to reflect change in behavior. --- source/NVDAObjects/behaviors.py | 24 ++++++++---------------- source/gui/settingsDialogs.py | 29 ++++------------------------- user_docs/en/userGuide.t2t | 10 ++-------- 3 files changed, 14 insertions(+), 49 deletions(-) diff --git a/source/NVDAObjects/behaviors.py b/source/NVDAObjects/behaviors.py index e191c2ba850..e252b344cc0 100755 --- a/source/NVDAObjects/behaviors.py +++ b/source/NVDAObjects/behaviors.py @@ -648,25 +648,17 @@ def event_suggestionsOpened(self): Subclasses should provide custom implementations if possible. By default NVDA will announce appearance of suggestions using speech, braille or a sound will be played. """ - reportAutoSuggestions = config.conf["presentation"]["reportAutoSuggestions"] - if reportAutoSuggestions in ("message", "sound"): - # Translators: Announced when suggestions appear when search term is entered in various search fields such as Start search box in Windows 10. - braille.handler.message(_("Suggestions")) - if reportAutoSuggestions == "message": - speech.speakMessage(_("Suggestions")) - elif reportAutoSuggestions == "sound": - nvwave.playWaveFile(r"waves\suggestionsOpened.wav") + # Translators: Announced in braille when suggestions appear when search term is entered in various search fields such as Start search box in Windows 10. + braille.handler.message(_("Suggestions")) + if config.conf["presentation"]["reportAutoSuggestionsWithSound"]: + nvwave.playWaveFile(r"waves\suggestionsOpened.wav") def event_suggestionsClosed(self): """Called when suggestions list or container is closed. Subclasses should provide custom implementations if possible. By default NVDA will announce this via speech, braille or via a sound. """ - reportAutoSuggestions = config.conf["presentation"]["reportAutoSuggestions"] - if reportAutoSuggestions in ("message", "sound"): - # Translators: Announced when suggestions disappear when search term is entered in various search fields such as Start search box in Windows 10. - braille.handler.message(_("Suggestions closed")) - if reportAutoSuggestions == "message": - speech.speakMessage(_("Suggestions closed")) - elif reportAutoSuggestions == "sound": - nvwave.playWaveFile(r"waves\suggestionsClosed.wav") + # Translators: Announced in braille when suggestions disappear when search term is entered in various search fields such as Start search box in Windows 10. + braille.handler.message(_("Suggestions closed")) + if config.conf["presentation"]["reportAutoSuggestionsWithSound"]: + nvwave.playWaveFile(r"waves\suggestionsClosed.wav") diff --git a/source/gui/settingsDialogs.py b/source/gui/settingsDialogs.py index f318f285f7c..482a6d75938 100644 --- a/source/gui/settingsDialogs.py +++ b/source/gui/settingsDialogs.py @@ -887,23 +887,6 @@ class ObjectPresentationDialog(SettingsDialog): ("both", _("Speak and beep")), ) - autoSuggestionsLabels = ( - # Translators: An option for auto-suggestions output in the Object Presentation dialog - # which disables reporting of appearance of suggestions. - # See Report auto-suggestions in the Object Presentation Settings section of the User Guide. - ("off", _("off")), - # Translators: An option for auto-suggestions output in the Object Presentation dialog - # which disables reporting of appearance of suggestions. - # See Report auto-suggestions in the Object Presentation Settings section of the User Guide. - - # which announces appearance of suggestions via speech and braille. - ("message", _("Message")), - # Translators: An option for auto-suggestions output in the Object Presentation dialog - # which reports appearance of suggestions via a sound. - # See Report auto-suggestions in the Object Presentation Settings section of the User Guide. - ("sound", _("Sound")), - ) - def makeSettings(self, settingsSizer): sHelper = guiHelper.BoxSizerHelper(self, sizer=settingsSizer) # Translators: This is the label for a checkbox in the @@ -968,13 +951,9 @@ def makeSettings(self, settingsSizer): # Translators: This is the label for a combobox in the # object presentation settings dialog. - autoSuggestionsLabelText = _("&Auto-suggestions notification:") - autoSuggestionsChoices = [name for setting, name in self.autoSuggestionsLabels] - self.autoSuggestionsList=sHelper.addLabeledControl(autoSuggestionsLabelText, wx.Choice,choices=autoSuggestionsChoices) - for index, (setting, name) in enumerate(self.autoSuggestionsLabels): - if setting == config.conf["presentation"]["reportAutoSuggestions"]: - self.autoSuggestionsList.SetSelection(index) - break + autoSuggestionsLabelText = _("Play a sound when &auto-suggestions appear") + self.autoSuggestionSoundsCheckBox=sHelper.addItem(wx.CheckBox(self,label=autoSuggestionsLabelText)) + self.autoSuggestionSoundsCheckBox.SetValue(config.conf["presentation"]["reportAutoSuggestionsWithSound"]) def postInit(self): self.tooltipCheckBox.SetFocus() @@ -989,7 +968,7 @@ def onOk(self,evt): config.conf["presentation"]["progressBarUpdates"]["progressBarOutputMode"]=self.progressLabels[self.progressList.GetSelection()][0] config.conf["presentation"]["progressBarUpdates"]["reportBackgroundProgressBars"]=self.reportBackgroundProgressBarsCheckBox.IsChecked() config.conf["presentation"]["reportDynamicContentChanges"]=self.dynamicContentCheckBox.IsChecked() - config.conf["presentation"]["reportAutoSuggestions"]=self.autoSuggestionsLabels[self.autoSuggestionsList.GetSelection()][0] + config.conf["presentation"]["reportAutoSuggestionsWithSound"]=self.autoSuggestionSoundsCheckBox.IsChecked() super(ObjectPresentationDialog, self).onOk(evt) class BrowseModeDialog(SettingsDialog): diff --git a/user_docs/en/userGuide.t2t b/user_docs/en/userGuide.t2t index dc86e290ae3..2467e8725a9 100644 --- a/user_docs/en/userGuide.t2t +++ b/user_docs/en/userGuide.t2t @@ -1120,19 +1120,13 @@ Key: NVDA+5 Toggles the announcement of new content in particular objects such as terminals and the history control in chat programs. -==== Auto-suggestions notification ==== -This option allows you to configure how NVDA will notify you of appearance of auto-suggestions. +==== Play a sound when auto-suggestions appear ==== +Toggles announcement of appearance of auto-suggestions, and if enabled, NVDA will play a sound to indicate this. Auto-suggestions are lists of suggested entries based on text entered into certain edit fields and documents. For example, when you enter text into the search box in Start menu in Windows Vista and later, Windows displays a list of suggestions based on what you typed. For some edit fields such as search fields in various Windows 10 apps, NVDA can notify you that a list of suggestions has appeared when you type text. The auto-suggestions list will close once you move away from the edit field, and for some fields, NVDA can notify you of this when this happens. -The ways in which NVDA can notify you of appearance of auto-suggestions are: -- Off: Appearance of suggestions will not be announced. -- Message: NVDA will speak or braille a message when suggestions appear. -- Sound: NVDA will play a sound when suggestions appear. -- - +++ Input Composition Settings +++ The Input Composition Settings dialog can be found under the Preferences menu. This dialog allows you to control how NVDA reports the input of Asian characters, such as with IME or Text Service input methods. From a9ceeb0ee31bf751253affc0c8c5be946745dbd9 Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Wed, 18 Jan 2017 22:30:07 -0800 Subject: [PATCH 19/26] Search suggestions: allow Windows 10 Start menu and Edge to provide search suggestions. re #6241. Reviewed by Mick Curran (NV Access): allow Start menu search box and Edge's address omnibar to participate in providing auto-suggestions announcement. --- source/NVDAObjects/UIA/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/NVDAObjects/UIA/__init__.py b/source/NVDAObjects/UIA/__init__.py index 58bae62916b..bd31add010d 100644 --- a/source/NVDAObjects/UIA/__init__.py +++ b/source/NVDAObjects/UIA/__init__.py @@ -603,8 +603,8 @@ def findOverlayClasses(self,clsList): if self.UIAIsWindowElement and UIAClassName in ("#32770","NUIDialog", "Credential Dialog Xaml Host"): clsList.append(Dialog) # #6241: Try detecting all possible suggestions containers and search fields scattered throughout Windows 10. - # But don't let suggestions list appearance be announced in Windows 10 Start menu for consistent experience with earlier Windows versions. - if self.UIAElement.cachedAutomationID == "TextBox": + # In Windows 10, allow Start menu search box and Edge's address omnibar to participate in announcing appearance of auto-suggestions. + if self.UIAElement.cachedAutomationID in ("SearchTextBox", "TextBox", "addressEditBox"): clsList.append(SearchField) try: # Nested block here in order to catch value error when attempting to access automation ID for invalid elements. From d58caeabfd4fe657b497c1f944f5ec18f07606fc Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Thu, 19 Jan 2017 07:49:08 -0800 Subject: [PATCH 20/26] Config: auto-suggestion setting is now part of configspec module. re #6241 --- source/config/configSpec.py | 1 + 1 file changed, 1 insertion(+) diff --git a/source/config/configSpec.py b/source/config/configSpec.py index 5735b7c89f1..f1bccc11f37 100644 --- a/source/config/configSpec.py +++ b/source/config/configSpec.py @@ -75,6 +75,7 @@ reportHelpBalloons = boolean(default=true) reportObjectDescriptions = boolean(default=True) reportDynamicContentChanges = boolean(default=True) + reportAutoSuggestionsWithSound = boolean(default=True) [[progressBarUpdates]] reportBackgroundProgressBars = boolean(default=false) #output modes are beep, speak, both, or off From d077a8badb777e78d3fb0aef99011438767ee0d7 Mon Sep 17 00:00:00 2001 From: Michael Curran Date: Thu, 11 May 2017 16:23:24 +1000 Subject: [PATCH 21/26] Update to miscDeps containing auto suggestions sounds. --- miscDeps | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/miscDeps b/miscDeps index 3efa98d052e..8987b2cfd5a 160000 --- a/miscDeps +++ b/miscDeps @@ -1 +1 @@ -Subproject commit 3efa98d052ef196db4d94303fb415525c890cb37 +Subproject commit 8987b2cfd5a86703053654741df7a160af585e27 From ba21c102e06882082d2899d6766e7755dc42da32 Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Thu, 11 May 2017 10:00:41 -0700 Subject: [PATCH 22/26] NVDAObjects.UIA: catch UnboundLocalError for parentElement if parentElement fetcher fails. re #6241. In some cases, when Start menu opens, it isn't announced by NVDA. As a result, parent element fetcher fails when trying to instantiate suggestions list item, with a traceback that ends with UnboundLocalError. Catch this by moving the SuggestionsListItem selector to inside of the try block. --- source/NVDAObjects/UIA/__init__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/NVDAObjects/UIA/__init__.py b/source/NVDAObjects/UIA/__init__.py index 25f4aa6ea51..37351a3febb 100644 --- a/source/NVDAObjects/UIA/__init__.py +++ b/source/NVDAObjects/UIA/__init__.py @@ -744,15 +744,15 @@ def findOverlayClasses(self,clsList): if self.UIAElement.cachedAutomationID in ("SearchTextBox", "TextBox", "addressEditBox"): clsList.append(SearchField) try: - # Nested block here in order to catch value error when attempting to access automation ID for invalid elements. + # Nested block here in order to catch value error and variable binding error when attempting to access automation ID for invalid elements. try: # #6241: Raw UIA base tree walker is better than simply looking at self.parent when locating suggestion list items. parentElement=UIAHandler.handler.baseTreeWalker.GetParentElementBuildCache(self.UIAElement,UIAHandler.handler.baseCacheRequest) + # Sometimes, fetching parent (list control) via base tree walker fails, especially when dealing with suggestions in Windows10 Start menu. + if parentElement.cachedAutomationId.lower()=="suggestionslist": + clsList.append(SuggestionListItem) except COMError: pass - # Sometimes, fetching parent (list control) via base tree walker fails, especially when dealing with suggestions in Windows10 Start menu. - if parentElement.cachedAutomationId.lower()=="suggestionslist": - clsList.append(SuggestionListItem) except ValueError: pass From 733c12c4f740e4e999c8347c4f5cafb9d374dca3 Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Wed, 31 May 2017 11:02:05 -0700 Subject: [PATCH 23/26] EditableTextWithSuggestions: remove braille message shown when suggestions close for consistency with other situations (such as browse mode toggle). re #6241. --- source/NVDAObjects/behaviors.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/source/NVDAObjects/behaviors.py b/source/NVDAObjects/behaviors.py index e252b344cc0..52e4e5a6f05 100755 --- a/source/NVDAObjects/behaviors.py +++ b/source/NVDAObjects/behaviors.py @@ -658,7 +658,5 @@ def event_suggestionsClosed(self): Subclasses should provide custom implementations if possible. By default NVDA will announce this via speech, braille or via a sound. """ - # Translators: Announced in braille when suggestions disappear when search term is entered in various search fields such as Start search box in Windows 10. - braille.handler.message(_("Suggestions closed")) if config.conf["presentation"]["reportAutoSuggestionsWithSound"]: nvwave.playWaveFile(r"waves\suggestionsClosed.wav") From e3a8cfcb8dbd5b9473b54054ad1111705004fd35 Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Wed, 31 May 2017 12:21:49 -0700 Subject: [PATCH 24/26] NVDAObjects.UIA.SuggestionListItem: braille suggestion results as flash messages. re #6241. Suggestion from Davy Kager: provide a way to let braille users read search suggestion items. This is done by emulating some parts of speech.SpeakObjectProperties except the name and position info map will be fetched (position info map fetching is contingent on whether report position info setting is enabled from Object Presentation dialog). Ideally, NVDA objects should have a way to fetch braille flash messages for controls. Also reworded docstring for SuggestionListItem so it cna include other UIA-based suggestion list items such as Windows 8.x search results. --- source/NVDAObjects/UIA/__init__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/source/NVDAObjects/UIA/__init__.py b/source/NVDAObjects/UIA/__init__.py index 9f7541cc7ca..c43c3a44f79 100644 --- a/source/NVDAObjects/UIA/__init__.py +++ b/source/NVDAObjects/UIA/__init__.py @@ -1465,7 +1465,7 @@ def event_UIA_controllerFor(self): class SuggestionListItem(UIA): - """Windows 10 uses suggestions lists for various things, including Start menu suggestions, Store, Settings app and so on. + """Recent Windows releases use suggestions lists for various things, including Start menu suggestions, Store, Settings app and so on. """ role=controlTypes.ROLE_LISTITEM @@ -1476,3 +1476,9 @@ def event_UIA_elementSelected(self): speech.cancelSpeech() api.setNavigatorObject(self) self.reportFocus() + # Construct the braille flash message (name, position info). + # Ideally NvDA objects should have a method to construct braille flash messages. + suggestionMessage=[self.name] + if config.conf["presentation"]["reportObjectPositionInformation"]: + suggestionMessage.append(_("{number} of {total}").format(number=self.positionInfo["indexInGroup"], total=self.positionInfo["similarItemsInGroup"])) + braille.handler.message(" ".join(suggestionMessage)) From 9ad4cf47c0f135c89d3b5bc4df9ab09880b7ea64 Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Wed, 31 May 2017 13:17:21 -0700 Subject: [PATCH 25/26] NVDAObjects.UIA.SuggestionsListItem: flash suggestion results in braille. re #6241, #6414. Instead of constructing the likely flash message, use a function used as part of Core issue 6414, which is much simpler than constructing the flash message from scratch. --- source/NVDAObjects/UIA/__init__.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/source/NVDAObjects/UIA/__init__.py b/source/NVDAObjects/UIA/__init__.py index c43c3a44f79..f2a4a4902aa 100644 --- a/source/NVDAObjects/UIA/__init__.py +++ b/source/NVDAObjects/UIA/__init__.py @@ -1476,9 +1476,5 @@ def event_UIA_elementSelected(self): speech.cancelSpeech() api.setNavigatorObject(self) self.reportFocus() - # Construct the braille flash message (name, position info). - # Ideally NvDA objects should have a method to construct braille flash messages. - suggestionMessage=[self.name] - if config.conf["presentation"]["reportObjectPositionInformation"]: - suggestionMessage.append(_("{number} of {total}").format(number=self.positionInfo["indexInGroup"], total=self.positionInfo["similarItemsInGroup"])) - braille.handler.message(" ".join(suggestionMessage)) + # Display results as flash messages. + braille.handler.message(braille.getBrailleTextForProperties(name=self.name, role=self.role, positionInfo=self.positionInfo)) From db6628d3dccdc7d6386773482a4fb071ddfabd1f Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Wed, 14 Jun 2017 18:15:35 -0700 Subject: [PATCH 26/26] UIA/SuggestionListItem/searchui: also classify Start search results context menu as a suggestions list item. re #6241. Oddly, the same behavior that's applied to suggestion items must work in Start suggestion's context menu, otherwise menu items will not be announced. --- source/NVDAObjects/UIA/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/NVDAObjects/UIA/__init__.py b/source/NVDAObjects/UIA/__init__.py index f2a4a4902aa..739c1b5d769 100644 --- a/source/NVDAObjects/UIA/__init__.py +++ b/source/NVDAObjects/UIA/__init__.py @@ -753,7 +753,8 @@ def findOverlayClasses(self,clsList): # #6241: Raw UIA base tree walker is better than simply looking at self.parent when locating suggestion list items. parentElement=UIAHandler.handler.baseTreeWalker.GetParentElementBuildCache(self.UIAElement,UIAHandler.handler.baseCacheRequest) # Sometimes, fetching parent (list control) via base tree walker fails, especially when dealing with suggestions in Windows10 Start menu. - if parentElement.cachedAutomationId.lower()=="suggestionslist": + # Oddly, we need to take care of context menu for Start search suggestions as well. + if parentElement.cachedAutomationId.lower() in ("suggestionslist", "contextmenu"): clsList.append(SuggestionListItem) except COMError: pass