Release lock on mouse keys when exiting.#13529
Conversation
There was a problem hiding this comment.
As mentioned in #13410 these should be announced.
I think the best way to do this is to move the code from script_toggleLeftMouseButton and script_toggleRightMouseButton into helper functions in mouseHandler.
For example, for the left button mouseHandler.isLeftButtonLocked(), mouseHandler.unlockLeftButton(), mouseHandler.lockLeftButton().
Make the scripts and mouseHandler.terminate call these functions.
|
|
||
| def terminate(): | ||
| global scrBmpObj, _shapeTimer | ||
| if winUser.getKeyState(winUser.VK_LBUTTON) & 32768: |
There was a problem hiding this comment.
It would be great to replace this magic number 32768 with a named constant such as MOUSE_BUTTON_DOWN.
Alternatively, we could create an IntEnum in keyboardHandler and import it.
class KeyState(IntEnum):
TOGGLED = 1
DOWN = 32768Replacing other usages of these constants can be done in a separate issue and pull request
There was a problem hiding this comment.
Actually the enum should probably use a bitshift or 0bx binary format, as MS docs defines these as
- If the high-order bit is 1, the key is down; otherwise, it is up.
- If the low-order bit is 1, the key is toggled. A key, such as the CAPS LOCK key, is toggled if it is turned on. The key is off and untoggled if the low-order bit is 0. A toggle key's indicator light (if any) on the keyboard will be on when the key is toggled, and off when the key is untoggled.
class KeyState(IntFlag):
"""
Mirrors the return values in GetKeyState (also used in GetAsyncKeyState)
https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getkeystate#return-value
"""
TOGGLED = 1
"""If the low-order bit is 1, the key is toggled.
The key is off and untoggled if the low-order bit is 0.
A key, such as the CAPS LOCK key, is toggled if it is turned on.
A toggle key's indicator light (if any) on the keyboard will be on when the key is toggled,
and off when the key is untoggled.
"""
DOWN = 1 << 15 # = 32768
"""If the high-order bit (of a 16 bit int) is 1, the key is down; otherwise, it is up."""|
One problem I have noticed is that NVDA exits before the ui messages are spoken. |
|
I too don't know whether it would be a good thing to halt exit until the messages have been spoken, although it would seem strange to announce something only to have it cut off. I though tend to make my screenreaders fairly low verbosity so I personally would not really choose to have these messages spoken in the first place. I could do with guidance on how this should be made to work and then I will look into making the code work that way. |
seanbudd
left a comment
There was a problem hiding this comment.
Providing messages during the exit of NVDA is a general pattern we haven't solved yet.
I think this can be merged as-is until we find an appropriate UX pattern to solve this problem.
|
I'm unable to commit the update to changes.t2t to update your repository fork. |
|
Well I am not too familiar with github and all its options. I did a rebase from master in git command line to bring this up to date with master. Not sure whether that deals with the issue of merging. The referenced github page also mentions having a "Allow edits by maintainers" checkbox checked, which it is on this pull request. If more is needed I will need greater explanation of what I need to do. |
|
Something very strange has happened with this rebase - would you be able to undo it? |
b9ad238 to
286ca26
Compare
|
I have done git reset --hard nvaccess/master and then reapplied my changes. Hopefully that sorts things out. |
|
Thanks, I realised pushing changes was a problem on my end. I'll merge this when the build finished. |
Link to issue number:
#13410
Summary of the issue:
If the user locks a mouse button and then exits NVDA, the mouse button remains locked.
Description of how this pull request fixes the issue:
The mouse button states are checked in terminate() of the mouseHandler and unlocks the mouse buttons as required.
Testing strategy:
Manually tested by locking the mouse button and then restarting NVDA.
Known issues with pull request:
None known.
Change log entries:
New features
Changes
Any locked mouse keys will be unlocked when NVDA exits, previously the mouse button would remain locked.
Bug fixes
For Developers
Code Review Checklist: