Py3.8: allow NVDA scripts to again run when in a wx popup menu or message box.#12072
Merged
michaelDCurran merged 1 commit intopy3.8from Feb 17, 2021
Merged
Py3.8: allow NVDA scripts to again run when in a wx popup menu or message box.#12072michaelDCurran merged 1 commit intopy3.8from
michaelDCurran merged 1 commit intopy3.8from
Conversation
…ger executes callbacks while NVDA's main thread is within apopup menu or message box. 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.
josephsl
approved these changes
Feb 14, 2021
Contributor
josephsl
left a comment
There was a problem hiding this comment.
Thanks- tested manually myself and works, too.
Collaborator
|
Is this change in WX actually a bug? How did you find out this workaround? |
Member
Author
|
I just found it out through trial and error.
I guess it could be seen as a wx bug, though I doubt it was designed
specifically to handle the way we use it in NVDA, even if it did work
previously. I.e. running arbitrary code (including other wx events)
within a popup menu or message box (which usually would be classed as
blocking) is not something that most apps do -- though very common in a
screen reader.
|
feerrenrut
approved these changes
Feb 15, 2021
Contributor
feerrenrut
left a comment
There was a problem hiding this comment.
Looks fine to me.
I've been through the checklist, they can all be ticked.
Could you please raise an issue on the wxPython issue tracker? This will help us to remove the workaround if / when the issue is fixed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.