Skip to content

Commit

Permalink
NVDAObjects/UIA/SearchField: announce suggestions count for search bo…
Browse files Browse the repository at this point in the history
…xes. re nvaccess#7330.

In some search fields, because one needs to use arrow keys to go through suggestions, it is important that people know how many suggestions are out there. Thus suggestionsOpened event in SearchField will announce this provided that report position information checkbox is checked in Object Presentation dialog.
  • Loading branch information
josephsl committed Jun 28, 2017
1 parent 3f9732c commit 3cb088e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions source/NVDAObjects/UIA/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
from NVDAObjects import NVDAObjectTextInfo, InvalidNVDAObject
from NVDAObjects.behaviors import ProgressBar, EditableTextWithoutAutoSelectDetection, Dialog, Notification, EditableTextWithSuggestions
import braille
import queueHandler
import ui

class UIATextInfo(textInfos.TextInfo):

Expand Down Expand Up @@ -1465,6 +1467,17 @@ def event_UIA_controllerFor(self):
else:
self.event_suggestionsClosed()

def event_suggestionsOpened(self):
super(SearchField, self).event_suggestionsOpened()
# #7330: Announce number of items found (except in Start search box where the suggestions are selected as user types).
# Oddly, Edge's address omnibar returns 0 for suggestion count when there are clearly suggestions (implementation differences).
# Because inaccurate count could be announced (when users type, suggestion count changes), thus announce this if position info reporting is enabled.
if config.conf["presentation"]["reportObjectPositionInformation"]:
if self.UIAElement.cachedAutomationID == "TextBox" or self.UIAElement.cachedAutomationID == "SearchTextBox" and self.appModule.appName != "searchui":
# Item count must be the last one announced.
# Translators: presented when there are suggestions as theu ser types (example output: 3 suggestions).
queueHandler.queueFunction(queueHandler.eventQueue, ui.message, _("{suggestionsCount} suggestions").format(suggestionsCount = self.controllerFor[0].childCount))


class SuggestionListItem(UIA):
"""Recent Windows releases use suggestions lists for various things, including Start menu suggestions, Store, Settings app and so on.
Expand Down

0 comments on commit 3cb088e

Please sign in to comment.