From fc1f9948b425ee4e3ca8353d5bfb604752007e5f Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Mon, 30 Nov 2020 12:39:17 -0800 Subject: [PATCH 1/4] Windows 10 Calculator: avoid unit conversion result repetition. Re #11880. If a user presses Escape several times while focused on either 'convert from' or 'converts into' fields in unit converter, NVDA will announce the field again after a number is entered. This was traced to result announcement flag that is checked from name change event handler. To avoid repetition, add UIA Automation Id's for these elements (Value1 and Value2, respectively) to a list of no result announcement Id's. --- source/appModules/calculator.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/appModules/calculator.py b/source/appModules/calculator.py index d2654677d37..7a36d62969e 100644 --- a/source/appModules/calculator.py +++ b/source/appModules/calculator.py @@ -26,6 +26,10 @@ "ContentPresenter", # Briefly shown when closing date calculation calendar. "Light Dismiss", + # Unit conversion/convert from. + "Value1", + # Unit conversion/converts into. + "Value2", ] From 9c4c1e2de2679678164f82dc6f1b94a4fb910cf0 Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Mon, 30 Nov 2020 12:40:35 -0800 Subject: [PATCH 2/4] Windows 10 Calculator: remove unit conversion Automation Id's from name change event handler element check. Re #11880. Now that unit converter element Automation Id's were added to no result nanouncement list, there's no need to check for these in name change event handler. --- source/appModules/calculator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/appModules/calculator.py b/source/appModules/calculator.py index 7a36d62969e..4eb9a6854fd 100644 --- a/source/appModules/calculator.py +++ b/source/appModules/calculator.py @@ -55,7 +55,7 @@ def event_nameChange(self, obj, nextHandler): ): # For unit conversion, UIA notification event presents much better messages. # For date calculation, live region change event is also fired for difference between dates. - if obj.UIAAutomationId not in ("Value1", "Value2", "DateDiffAllUnitsResultLabel"): + if obj.UIAAutomationId != "DateDiffAllUnitsResultLabel": ui.message(obj.name) self._resultsCache = obj.name if not self._shouldAnnounceResult: From f5b5315be124ae9df63d3b6659ab864a000daa87 Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Mon, 30 Nov 2020 12:45:21 -0800 Subject: [PATCH 3/4] Windows 10 Calculator: announce calculation results in compact overlay (always on top) mode. Re #11881. Always on top (compact overlay) mode uses a different UIA Automation Id to represent results. Therefore add this to a list of Id's to be checked when handling results script (Enter, Numpad Enter, Escape). --- source/appModules/calculator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/appModules/calculator.py b/source/appModules/calculator.py index 4eb9a6854fd..bbc3b32e4a8 100644 --- a/source/appModules/calculator.py +++ b/source/appModules/calculator.py @@ -98,7 +98,7 @@ def script_calculatorResult(self, gesture): # Hack: only announce display text when an actual calculator button (usually equals button) is pressed. # In redstone, pressing enter does not move focus to equals button. if isinstance(focus, UIA): - if focus.UIAAutomationId == "CalculatorResults": + if focus.UIAAutomationId in ("CalculatorResults", "CalculatorAlwaysOnTopResults"): queueHandler.queueFunction(queueHandler.eventQueue, focus.reportFocus) else: resultsScreen = api.getForegroundObject().children[1].lastChild From cb9af7dedc2e90446d218b08f1af3ade799457e5 Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Tue, 1 Dec 2020 01:40:52 -0800 Subject: [PATCH 4/4] Windows 10 Calculator/name change event handler: update unit converter comment. Re #11880 --- source/appModules/calculator.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/appModules/calculator.py b/source/appModules/calculator.py index bbc3b32e4a8..9d00eb81a34 100644 --- a/source/appModules/calculator.py +++ b/source/appModules/calculator.py @@ -53,7 +53,8 @@ def event_nameChange(self, obj, nextHandler): obj.UIAAutomationId not in noCalculatorEntryAnnouncements and obj.name != self._resultsCache ): - # For unit conversion, UIA notification event presents much better messages. + # For unit conversion, both name change and notification events are fired, + # although UIA notification event presents much better messages. # For date calculation, live region change event is also fired for difference between dates. if obj.UIAAutomationId != "DateDiffAllUnitsResultLabel": ui.message(obj.name)