Py3.8: allow NVDA scripts to again run when in a wx popup menu or message box. #12072
+15
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Link to issue number:
Fixes #12058
Summary of the issue:
If NVDA is run with wxPython 4.1.1, NVDA-specific key commands (scripts) fail to execute while in a WX popup menu (such as the NVDA menu) or wx message box (such as the NVDA About dialog). Yet, key commands that are not trapped by NVDA (E.g. pressing downArrow in a menu) still work okay.
In recent versions of wxWidgets, if in a menu or message box, calling wxWidget's CallAfter function does not execute the given callback until the menu or message box is dismissed (I.e. the wx main loop is again running). There are some exceptions to this, such as if a key or other input is sent to the application. But of course in the case of trying to execute an NVDA-specific command, NVDA blocks the key from getting to the application and therefore the wx event loop never wakes up.
In wxWidgets, it looks like CallAfter calls QueueEvent, which calls WakeupIdle.
Further investigation shows that queuing any kind of wx event (command, idle etc) does not wake up the wx event loop while in popup menus or message boxes.
Description of how this pull request fixes the issue:
Monkeypatch wx.CallAfter to post a WM_NULL message to our top-level window after calling the original CallAfter, which causes wx's event loop to wake up enough to execute the callback.
Testing strategy:
Note: this pr (nor the py3.8 branch at time of this comment) does not yet specifically use wxPython 4.1.1, thus it is necessary for testing that you first:
This pr has so far been tested manually by:
Unit tests do not apply to this pr as the issue is within wxPython.
System testing is certainly possible here. But only once wxPython 4.1.1 is in NVDA.
Known issues with pull request:
None.
Change log entry:
None needed.
Code Review Checklist:
This checklist is a reminder of things commonly forgotten in a new PR.
Authors, please do a self-review and confirm you have considered the following items.
Mark items you have considered by checking them.
You can do this when editing the Pull request description with an x:
[ ]
becomes[x]
.You can also check the checkboxes after the PR is created.