From f84a7d9f8b7102bac201fab0674cf9ff7ff1987c Mon Sep 17 00:00:00 2001 From: Julien Cochuyt Date: Thu, 29 Apr 2021 02:12:27 +0200 Subject: [PATCH] Speech Viewer: allow to close with alt+F4 & add a close button on the title bar for use with pointing devices (#10791) (#12330) The Speech Viewer currently has no close button nor can be closed with alt+F4. As described by @Qchristensen in #10791 (comment), most dialogs in NVDA can be closed with alt+F4. As argued by @bhavyashah in #10791 (comment), the Speech Viewer is especially useful for sighted testers who might be more familiar in using pointing devices than keyboard shortcuts. Description of how this pull request fixes the issue: Handle closing with alt+F4 & add a standard close button in the title bar of the dialog. Co-authored-by: Sean Budd --- source/gui/__init__.py | 7 ++++--- source/speechViewer.py | 11 ++++------- user_docs/en/changes.t2t | 1 + 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/source/gui/__init__.py b/source/gui/__init__.py index b812bab9324..4098735ec7e 100644 --- a/source/gui/__init__.py +++ b/source/gui/__init__.py @@ -1,7 +1,7 @@ # -*- coding: UTF-8 -*- # A part of NonVisual Desktop Access (NVDA) -# Copyright (C) 2006-2020 NV Access Limited, Peter Vágner, Aleksey Sadovoy, Mesar Hameed, Joseph Lee, -# Thomas Stivers, Babbage B.V. +# Copyright (C) 2006-2021 NV Access Limited, Peter Vágner, Aleksey Sadovoy, Mesar Hameed, Joseph Lee, +# Thomas Stivers, Babbage B.V., Accessolutions, Julien Cochuyt # This file is covered by the GNU General Public License. # See the file COPYING for more details. @@ -439,7 +439,8 @@ def __init__(self, frame): item = menu_tools.Append(wx.ID_ANY, _("View log")) self.Bind(wx.EVT_MENU, frame.onViewLogCommand, item) # Translators: The label for the menu item to toggle Speech Viewer. - item=self.menu_tools_toggleSpeechViewer = menu_tools.AppendCheckItem(wx.ID_ANY, _("Speech viewer")) + item = self.menu_tools_toggleSpeechViewer = menu_tools.AppendCheckItem(wx.ID_ANY, _("Speech viewer")) + item.Check(speechViewer.isActive) self.Bind(wx.EVT_MENU, frame.onToggleSpeechViewerCommand, item) self.menu_tools_toggleBrailleViewer: wx.MenuItem = menu_tools.AppendCheckItem( diff --git a/source/speechViewer.py b/source/speechViewer.py index 7109b55eead..7c293d6d466 100644 --- a/source/speechViewer.py +++ b/source/speechViewer.py @@ -1,5 +1,5 @@ # A part of NonVisual Desktop Access (NVDA) -# Copyright (C) 2006-2020 NV Access Limited, Thomas Stivers +# Copyright (C) 2006-2021 NV Access Limited, Thomas Stivers, Accessolutions, Julien Cochuyt # This file is covered by the GNU General Public License. # See the file COPYING for more details. @@ -38,7 +38,7 @@ def __init__(self, onDestroyCallBack): title=_("NVDA Speech Viewer"), size=dialogSize, pos=dialogPos, - style=wx.CAPTION | wx.RESIZE_BORDER | wx.STAY_ON_TOP + style=wx.CAPTION | wx.CLOSE_BOX | wx.RESIZE_BORDER | wx.STAY_ON_TOP ) self._isDestroyed = False self.onDestroyCallBack = onDestroyCallBack @@ -97,10 +97,8 @@ def _onDialogActivated(self, evt): self.shouldShowOnStartupCheckBox.SetFocus() def onClose(self, evt): - if not evt.CanVeto(): - deactivate() - return - evt.Veto() + assert isActive, "Cannot close Speech Viewer as it is already inactive" + deactivate() def onShouldShowOnStartupChanged(self, evt): config.conf["speechViewer"]["showSpeechViewerAtStartup"] = self.shouldShowOnStartupCheckBox.IsChecked() @@ -185,4 +183,3 @@ def deactivate(): # #7077: If the window is destroyed, text control will be gone, so save speech viewer position before destroying the window. _guiFrame.savePositionInformation() _guiFrame.Destroy() - isActive = False diff --git a/user_docs/en/changes.t2t b/user_docs/en/changes.t2t index ebe8bb7adf9..1791789766b 100644 --- a/user_docs/en/changes.t2t +++ b/user_docs/en/changes.t2t @@ -25,6 +25,7 @@ What's New in NVDA - New braille tables: Belarusian literary braille, Belarusian computer braille, Urdu grade 1, Urdu grade 2. - Support for Adobe Flash content has been removed from NVDA due to the use of Flash being actively discouraged by Adobe. (#11131) - NVDA will exit even with windows still open, the exit process now closes all NVDA windows and dialogs (#1740) +- The Speech Viewer can now be closed with `alt+F4` and has a standard close button for easier interaction with users of pointing devices. (#12330) == Bug Fixes ==