Skip to content

Commit f7049fd

Browse files
authored
When announcing calculation result in Win32 calculator rely on name change events (#15377)
Fixes #15230 Summary of the issue: NVDA's calculation announcements for Win32 calculator relies on a list of predefined keyboard commands, which, when pressed, causes the new value of the display to be announced. This assumes that at the time when gesture is sent the calculator had enough time to process it, and display the result of the calculation. While this worked before prior to #14708, after this PR NVDA no longer sleeps after sending gestures, therefore the value on calculator's display had not enough time to be updated. For users this means that after performing calculations the outdated value was read. Description of user facing changes NVDA once again announces correct results of the calculation. Description of development approach Rather than announcing the display value immediately after user pressed a key, NVDA now sets a flag signaling that the given command causes result of a calculation to appear. This flag is checked in the name change event for the display. If it is set the result is announced and the flag is restored to its default value. While at it I have also updated the copyright header of the module based on its log in VCS.
1 parent 4731401 commit f7049fd

2 files changed

Lines changed: 18 additions & 7 deletions

File tree

‎source/appModules/calc.py‎

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
#appModules/calc.py
2-
#A part of NonVisual Desktop Access (NVDA)
3-
#Copyright (C) 2007-2012 NV Access Limited
4-
#This file is covered by the GNU General Public License.
5-
#See the file COPYING for more details.
1+
# A part of NonVisual Desktop Access (NVDA)
2+
# Copyright (C) 2007-2023 NV Access Limited, Aleksey Sadovoy, Peter Vágner, Joseph Lee, Łukasz Golonka
3+
# This file may be used under the terms of the GNU General Public License, version 2 or later.
4+
# For more details see: https://www.gnu.org/licenses/gpl-2.0.html
65

76
"""App module for Windows Calculator (desktop version)
87
"""
@@ -11,6 +10,7 @@
1110
import NVDAObjects.IAccessible
1211
import speech
1312

13+
1414
class AppModule(appModuleHandler.AppModule):
1515

1616
def chooseNVDAObjectOverlayClasses(self, obj, clsList):
@@ -21,9 +21,12 @@ def chooseNVDAObjectOverlayClasses(self, obj, clsList):
2121
):
2222
clsList.insert(0, Display)
2323

24+
2425
class Display(NVDAObjects.IAccessible.IAccessible):
2526

2627
shouldAllowIAccessibleFocusEvent=True
28+
_nextNameIsCalculationResult: bool = False
29+
"""Set to `True` by the gestures which cause the calculator expression to be calculated."""
2730

2831
calcCommandChars=['!','=','@','#']
2932

@@ -42,12 +45,19 @@ def _get_name(self):
4245
def event_typedCharacter(self,ch):
4346
super(Display,self).event_typedCharacter(ch)
4447
if ch in self.calcCommandChars:
45-
speech.speakObjectProperties(self,value=True)
48+
self._nextNameIsCalculationResult = True
4649

4750
def script_executeAndRead(self,gesture):
4851
gesture.send()
49-
speech.speakObjectProperties(self,value=True)
52+
self._nextNameIsCalculationResult = True
5053

5154
def initOverlayClass(self):
5255
for g in Display.calcCommandGestures:
5356
self.bindGesture(g,"executeAndRead")
57+
58+
def event_nameChange(self):
59+
"""If the name change is a result of an expression its value is announced."""
60+
if self._nextNameIsCalculationResult:
61+
self._nextNameIsCalculationResult = False
62+
speech.speakObjectProperties(self, value=True)
63+
super().event_nameChange()

‎user_docs/en/changes.t2t‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ What's New in NVDA
5757
- Fixed bug where Albatross braille displays try to initialize although another braille device has been connected. (#15226)
5858
-
5959
- Fixed support for System List view (``SysListView32``) controls in Windows Forms applications. (#15283)
60+
- NVDA once again announces calculation results in the Windows 32bit calculator on Server, LTSC and LTSB versions of Windows. (#15284)
6061
-
6162

6263
== Changes for Developers ==

0 commit comments

Comments
 (0)