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

UIA objects: introduce a global suggestion list item class for Windows 10. re #6241 #6274

Merged
merged 31 commits into from
Jun 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
2300881
UIA objects: introduce a global suggestion list item class for Window…
josephsl Aug 17, 2016
8cb96b1
SearchUI: remove unneeded imports
josephsl Aug 18, 2016
fb57f8f
UIA handler: add proper copyright header (based on Git log archive)
josephsl Aug 9, 2016
41d729a
UIA: add support for Controller For property. re #6241
josephsl Aug 18, 2016
745a538
Revert "UIA: add support for Controller For property. re #6241"
josephsl Aug 18, 2016
5eb1978
UIA: add support for Controller For property. re #6241
josephsl Aug 18, 2016
665bdbd
NVDAObjects.UIA: introduce Search Field that'll handle controller for…
josephsl Aug 18, 2016
09a1471
Search Field: check if search field is focused before asking for cont…
josephsl Oct 27, 2016
a3d6af0
Update copyright years, add a docstring to UIA objects (__init__).
josephsl Jan 18, 2017
0d1f5af
Suggestion: a new behavior to allow NVDA to detect and announce sugge…
josephsl Jan 18, 2017
e04e7af
UIA objects/Search field: use the new NVDAObjects.behaviors.Suggestio…
josephsl Jan 18, 2017
1904711
UIA objects/suggestions list: use raw UIA base tree walker to obtain …
josephsl Jan 18, 2017
b3c0874
UIA objects: updated comments, removed reference to Redstone.
josephsl Jan 18, 2017
e253c57
UIA objects/Search field: don't allow suggestions detection be announ…
josephsl Jan 18, 2017
f51fa69
NVDAObjects/behaviors: rename 'Suggestion' to 'EditableTextWithSugges…
josephsl Jan 18, 2017
35a639d
Auto-suggestions: add a combo box in object presentation settings to …
josephsl Jan 19, 2017
f088b1b
User guide: document auto-suggestions notification setting. re #6241.
josephsl Jan 19, 2017
7f80407
Auto-suggestions: either play a sound or do nothing. re #6241.
josephsl Jan 19, 2017
a9ceeb0
Search suggestions: allow Windows 10 Start menu and Edge to provide s…
josephsl Jan 19, 2017
d58caea
Config: auto-suggestion setting is now part of configspec module. re …
josephsl Jan 19, 2017
783dc6a
Merge branch 'master' into pr/6274
michaelDCurran May 4, 2017
d077a8b
Update to miscDeps containing auto suggestions sounds.
michaelDCurran May 11, 2017
4bd6582
Merge branch 'master' into i6241UIASuggestionListItem
josephsl May 11, 2017
ba21c10
NVDAObjects.UIA: catch UnboundLocalError for parentElement if parentE…
josephsl May 11, 2017
cb3d6cf
Merge branch 'master' into i6241UIASuggestionListItem
josephsl May 31, 2017
733c12c
EditableTextWithSuggestions: remove braille message shown when sugges…
josephsl May 31, 2017
e3a8cfc
NVDAObjects.UIA.SuggestionListItem: braille suggestion results as fla…
josephsl May 31, 2017
9ad4cf4
NVDAObjects.UIA.SuggestionsListItem: flash suggestion results in brai…
josephsl May 31, 2017
a6d630a
Merge branch 'master' into i6241UIASuggestionListItem
josephsl Jun 15, 2017
db6628d
UIA/SuggestionListItem/searchui: also classify Start search results c…
josephsl Jun 15, 2017
9a02c20
Merge branch 'master' into i6241UIASuggestionListItem
josephsl Jun 23, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion miscDeps
51 changes: 48 additions & 3 deletions source/NVDAObjects/UIA/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#See the file COPYING for more details.
#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
from comtypes import COMError
Expand All @@ -25,7 +27,7 @@
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, EditableTextWithSuggestions
import braille

class UIATextInfo(textInfos.TextInfo):
Expand Down Expand Up @@ -738,9 +740,26 @@ 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.
# 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 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.
# 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
except ValueError:
pass

clsList.append(UIA)

Expand Down Expand Up @@ -1418,7 +1437,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:
Expand All @@ -1435,3 +1454,29 @@ def event_nameChange(self):
def event_stateChange(self):
return

class SearchField(EditableTextWithSuggestions, UIA):
"""An edit field that presents suggestions based on a search term.
"""

def event_UIA_controllerFor(self):
# Only useful if suggestions appear and disappear.
if self == api.getFocusObject() and len(self.controllerFor)>0:
self.event_suggestionsOpened()
else:
self.event_suggestionsClosed()


class SuggestionListItem(UIA):
"""Recent Windows releases use 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()
# Display results as flash messages.
braille.handler.message(braille.getBrailleTextForProperties(name=self.name, role=self.role, positionInfo=self.positionInfo))
29 changes: 28 additions & 1 deletion source/NVDAObjects/behaviors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -26,6 +27,7 @@
import api
import ui
import braille
import nvwave

class ProgressBar(NVDAObject):

Expand Down Expand Up @@ -633,3 +635,28 @@ def event_alert(self):
braille.handler.message(braille.getBrailleTextForProperties(name=self.name, role=self.role))

event_show = event_alert

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 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, braille or a sound will be played.
"""
# 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.
"""
if config.conf["presentation"]["reportAutoSuggestionsWithSound"]:
nvwave.playWaveFile(r"waves\suggestionsClosed.wav")
6 changes: 6 additions & 0 deletions source/UIAHandler.py
Original file line number Diff line number Diff line change
@@ -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
from comtypes import COMError
import config
Expand Down
7 changes: 7 additions & 0 deletions source/_UIAHandler.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
#_UIAHandler.py
#A part of NonVisual Desktop Access (NVDA)
#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 ctypes import *
from ctypes.wintypes import *
import comtypes.client
Expand Down Expand Up @@ -117,6 +123,7 @@
UIA_IsEnabledPropertyId:"stateChange",
UIA_ValueValuePropertyId:"valueChange",
UIA_RangeValueValuePropertyId:"valueChange",
UIA_ControllerForPropertyId:"UIA_controllerFor",
}

UIAEventIdsToNVDAEventNames={
Expand Down
23 changes: 2 additions & 21 deletions source/appModules/searchui.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,15 @@
#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.

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

# 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.
Expand Down
1 change: 1 addition & 0 deletions source/config/configSpec.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,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
Expand Down
7 changes: 7 additions & 0 deletions source/gui/settingsDialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -949,6 +949,12 @@ 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 = _("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()

Expand All @@ -962,6 +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"]["reportAutoSuggestionsWithSound"]=self.autoSuggestionSoundsCheckBox.IsChecked()
super(ObjectPresentationDialog, self).onOk(evt)

class BrowseModeDialog(SettingsDialog):
Expand Down
7 changes: 7 additions & 0 deletions user_docs/en/userGuide.t2t
Original file line number Diff line number Diff line change
Expand Up @@ -1165,6 +1165,13 @@ Key: NVDA+5

Toggles the announcement of new content in particular objects such as terminals and the history control in chat programs.

==== 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.

+++ 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.
Expand Down