[Bug]: macOS backend reports wrong button for button_release_event#31937
[Bug]: macOS backend reports wrong button for button_release_event#31937mishanilkazreen wants to merge 1 commit into
Conversation
|
Thank you for opening your first PR into Matplotlib! If you have not heard from us in a week or so, please leave a new comment below and that should bring it to our attention. Most of our reviewers are volunteers and sometimes things fall through the cracks. We also ask that you please finish addressing any review comments on this PR and wait for it to be merged (or closed) before opening a new one, as it can be a valuable learning experience to go through the review process. You can also join us on discourse chat for real-time discussion. For details on testing, writing docs, and our review process, please see the developer guide. We strive to be a welcoming and open project. Please follow our Code of Conduct. |
|
Thanks for this! Your solution for the macOS backend made me realize a potential issue that I forgot to check in the original bug. Consider the following:
qtagg with your PR prints: If you do the same with Control instead of Alt/Option, qtagg instead prints: I suspect that we want Alt/Option to show |
Fixes #31899
PR summary
The issue reports on macOS that Option+click and Ctrl+click were not correctly mapped to middle and right button clicks, respectively.
In qtagg, Option+click was hardcoded to
button = 1asbackend_qt.pydid not contain a button modifier mapping. Soevent.button()returned the physical button, which resulted in Option+click incorrectly emulating button 1 instead of button 2.In macosx, the
mouseDown:method was correctly mapped, however,mouseUp:hardcodedbutton = 1, which resulted in press and release being inconsistent.Fixes
For qtagg, I added a
_remap_darwin_button(...)static method inbackend_qt.pythat maps Alt/Option+left-click to the middle button on macOS.For macosx, I added a static variable
effectiveLeftButtonto store the resolved button at press time, allowingmouseUp:to read it back instead of hardcoding1.Minimum self-contained example
Instructions:
Outputs
Current
macosx
qtagg (PyQt6)
With Fixes
macosx & qtagg
Question
As raised in the initial issue, should the intended behaviour for the action
Alt + left-clickresult in the middle mouse? This implements it, but can be dropped by removing_remap_darwin_button(...)helper function.AI Disclosure
Claude Opus 4.8 was utilised to proofread my changes.
PR checklist