Skip to content

Commit

Permalink
NVDAObjects.UIA: introduce Search Field that'll handle controller for…
Browse files Browse the repository at this point in the history
… and announce appearance of suggestions. re nvaccess#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).
  • Loading branch information
josephsl committed Jan 18, 2017
1 parent b38e7c8 commit 9800b13
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion source/NVDAObjects/UIA/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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.
"""
Expand Down

0 comments on commit 9800b13

Please sign in to comment.