-
-
Notifications
You must be signed in to change notification settings - Fork 654
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement the gui.messageBox API #13007
Comments
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
I think this is unrelated as these controls don't use |
This comment was marked as duplicate.
This comment was marked as duplicate.
…essageBoxActive (#13376) Relates to #13007, as the new design should be backwards compatible, we can implement the API changes as-is for 2022.1. Follow up to the API proposed in #12984 Summary of the issue: The API for gui.message had not yet been determined for 2022.1, as per #13007. As the future API is intended to be backwards compatible, this PR commits to the API proposed in #12984. Description of how this pull request fixes the issue: gui.IsInMessageBox was a boolean, this has been replaced by a function gui.message.isModalMessageBoxActive, which tracks if a messageBox is open in a safer manner. Changes logic gui/message.py to be safer with locking and handling errors.
We have similar functions in NVDA that should be assimilated into a final design:
|
Ensure that the test It was tagged with I've added this to the description. |
Closes #13007 Closes #12344 Closes #12353 Summary of the issue: Currently, there are several ways to create message boxes/dialogs in NVDA, all of them with their own drawbacks. Additionally, subclassing `wx.Dialog` (or using it directly) brings with it the risk of breaking parts of NVDA. See #13007 for in-depth discussion. Thus, a new API for creating highly customizable dialogs that work well with NVDA is desired. Description of user facing changes This PR does not, in itself, introduce any end-user facing changes. However, it lays the groundwork for closing a number of issues. Description of development approach Subclassed `wx.Dialog` to add the desired functionality in #13007 Re-implemented the about box to use a `MessageDialog`. Added a callback field to `gui.blockAction._Context` to allow adding a function to execute when the block condition is met. Features and tasks * [x] Rename buttons * [x] Add custom buttons * [x] Associate context help with the given message box * [x] Show the dialog as a modal or a non-modal * [x] for non modal dialogs: * [x] provide a default return code when dialogs are forced to close (eg via an exit, perform cancel) (WIP) * [x] attach a callback to handle return codes * [x] refocus a dialog in the event of needing to close it * [x] if a default return code is provided, make the dialog close-able with alt+F4 and escape (WIP) * [x] for modal dialogs: * [x] if wx.CANCEL is provided, make the dialog close-able with alt+F4 and escape (mostly done) * [x] nice to have: * [x] if wx.CANCEL is provided, perform this action when dialogs are forced to close. * [x] refocus a dialog in the event of needing to close it * [x] Ensure that the test `Quits from keyboard with about dialog open` is re-enabled and works. * [x] Block exiting NVDA with modal `MessageDialog`s open. * [x] Focus open `MessageDialog`s without default actions when exiting. * [x] Tests * [x] Unit tests * [x] Document the new API in the developer guide * [x] Migrate the new API from `gui.MessageDialog` to `gui.message`. * [x] Mark other means of creating message dialogs as deprecated. * [x] Re implement their internals to use the new API * [x] `gui.message.messageBox` * [x] `gui.nvdaControls.MessageDialog` * [x] `gui.nvdaControls._ContinueCancelDialog` Testing strategy: Unit and manual tests. Unit tests are extensive, and reach around 85% coverage of the newly added code. Message box shim tested with a variety of inputs and unittests. This is a fairly straightforward adapter. `nvdaControls.MessageDialog` tested that screen curtain and add-on install warning dialogs still work as expected. Its private subclass, `_ContinueCancelDialog`, was tested by attempting to run the CRFT. Known issues with pull request: Internal dialogs are yet to be migrated. This should be done gradually before the existing means of creating message dialogs are removed. Slightly odd behaviour when a callback function blocks, and `focusBlockingInstances` is called, where a hidden dialog is focused. This can be worked around, but possibly not without unintended consequences. Some invalid combinations (namely a button which is set as the default action but set not to close the dialog) are silently changed. While documenting this should be sufficient, logging or raising an exception may be warranted. Visual proportions of the re-implemented About dialog are different. The `ctrl+c` behaviour of copying the dialog's title, contents and buttons is not supported. Future work * Remove all internal use of deprecated message dialog APIs. * Remove deprecated message dialog APIs in 2026.1. Nice to have * Implement system tests for the new API. * Comprehensively document a manual test plan, and develop any associated scripts. * Add the ability to set a callback after a button has been added. * Add a helper to add a "don't show this message again" checkbox.
This reverts commit 2477780. Reverts #17304 Issues fixed Fixes #17560 Fixes #17553 Issues reopened Reopens #13007 Reopens #12344 Reopens #12353 Reason for revert This PR broke two important NVDA functions, and there is insufficient time before the Christmas/New Years break to fix the issues, so we are temporarily reverting so that alphas work over the break: • The CRFT no longer works, as gui.message.MessageDialog's inheritance from ContextHelpMixin was accidentally removed. • Update checking no longer works, as runScriptModalDialog was modified to increment and decrement _messageBoxCounter, but UpdateAskInstallDialog attempts to restart NVDA before it has been closed, so the update fails as NVDA appears to be in an unsafe state.
See also: #12344, #12353, #10799, #8709, #13579
Current problems:
wx.OK or wx.CANCEL
as an option cannot be closed withAlt+F4/Escape
Quits from keyboard with about dialog open
is re-enabled and works. Tagged with# Excluded to be fixed still (#12976)
, however that issue is closed.Requirements for the API
A developer should be able to:
wx.CANCEL
is provided, make the dialog close-able with alt+F4 and escapewx.CANCEL
is provided, perform this action when dialogs are forced to close.Constraints from wxPython
Support across
wx.MessageBox
,wx.MessageDialog
andwx.Dialog
for the following:wx.CANCEL
is an option for thewx.MessageBox/wx.MessageDialog
. If Yes/No is required, we should not accept alt+F4 and escapewx.CANCEL
should replacewx.NO
and the buttons should be renamed appropriatelywx.Dialog
orwx.MessageDialog
is required to add the following:wx.MessageBox
is a function that doesn't support this.Using
wx.MessageDialog
directly also can implement this.wx.Dialog
with.Show
is required to add the following :wx.Dialog.ShowModal
is blocking, so.Show
must be used.wx.MessageBox
andwx.MessageDialog
doesn't support.Show()
, butwx.Dialog
does.Suggestions moving forward:
In 2022.1:
gui.IsInMessageBox
was a boolean, this has been replaced by a functiongui.message.isModalMessageBoxActive
, which tracks if a messageBox is open in a safer manner. Done in Replace boolean gui.IsInMessageBox with function gui.message.isModalMessageBoxActive #13376 .In a future release
gui.MessageDialog
class, encourage migration to using it instead ofgui.messageBox
.gui.messageDialog
should not subclasswx.MessageDialog
, and instead be a customwx.Dialog
subclassShow
andShowModal
to track instances to track inIsInMessageBox
wx.CANCEL
should be replaced withwx.NO
to enable esc/alt+f4, with the buttons renamedReference documentation
Additional context
Fix up #12984
#12976
Draft Sample API
The text was updated successfully, but these errors were encountered: