Title: [Bug]: macOS backend reports wrong button for button_release_event · Issue #31899 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: macOS backend reports wrong button for button_release_event · Issue #31899 · matplotlib/matplotlib
X Title: [Bug]: macOS backend reports wrong button for button_release_event · Issue #31899 · matplotlib/matplotlib
Description: Bug summary Run the attached code with the qtagg as well as the macosx backends. While the mouse cursor is over the figure, perform the following: Click mouse. Release mouse Hold Option: Click mouse. Release mouse. Hold Control: Click mo...
Open Graph Description: Bug summary Run the attached code with the qtagg as well as the macosx backends. While the mouse cursor is over the figure, perform the following: Click mouse. Release mouse Hold Option: Click mous...
X Description: Bug summary Run the attached code with the qtagg as well as the macosx backends. While the mouse cursor is over the figure, perform the following: Click mouse. Release mouse Hold Option: Click mous...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/31899
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: macOS backend reports wrong button for button_release_event","articleBody":"### Bug summary\n\nRun the attached code with the qtagg as well as the macosx backends.\n\nWhile the mouse cursor is over the figure, perform the following:\n\n1. Click mouse. Release mouse\n2. Hold Option: Click mouse. Release mouse.\n3. Hold Control: Click mouse. Release mouse.\n\n### Code for reproduction\n\n```Python\nimport matplotlib.pyplot as plt\n\ndef on_button_press(event):\n print(f'button press: {event.button}')\ndef on_button_release(event):\n print(f'button release: {event.button}')\n\nfig = plt.figure()\nfig.canvas.mpl_connect('button_press_event', on_button_press)\nfig.canvas.mpl_connect('button_release_event', on_button_release)\n\nplt.show()\n```\n\n### Actual outcome\n\nqtagg:\n\n```\nbutton press: 1\nbutton release: 1\nbutton press: 1\nbutton release: 1\nbutton press: 3\nbutton release: 3\n```\n\nmacosx:\n\n```\nbutton press: 1\nbutton release: 1\nbutton press: 2\nbutton release: 1\nbutton press: 3\nbutton release: 1\n```\n\n\n### Expected outcome\n\nBased on these code comments in `_macosx.m`:\n\n```c\nif (modifier \u0026 NSEventModifierFlagControl)\n /* emulate a right-button click */\n button = 3;\nelse if (modifier \u0026 NSEventModifierFlagOption)\n /* emulate a middle-button click */\n button = 2;\n```\n\nI would expect:\n\n```\nbutton press: 1\nbutton release: 1\nbutton press: 2\nbutton release: 2\nbutton press: 3\nbutton release: 3\n```\n\nHowever, if alt+click should not result in \"middle click\", I would expect macosx to match qtagg.\n\n### Additional information\n\n_No response_\n\n### Operating system\n\nmacOS 14.8.5\n\n### Matplotlib Version\n\ndev\n\n### Matplotlib Backend\n\nqtagg, macosx\n\n### Python version\n\n3.14.5\n\n### Jupyter version\n\n_No response_\n\n### Installation\n\nNone","author":{"url":"https://github.com/iccir","@type":"Person","name":"iccir"},"datePublished":"2026-06-15T03:48:23.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/31899/matplotlib/issues/31899"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:8fe7102f-8c32-501c-c876-6013833519d2 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C996:3008D0:157092D:1F40077:6A5783F9 |
| html-safe-nonce | ee54da20c8e8a454924c2ab22260d5ce88aabbc742e478858edd93b220033e63 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDOTk2OjMwMDhEMDoxNTcwOTJEOjFGNDAwNzc6NkE1NzgzRjkiLCJ2aXNpdG9yX2lkIjoiMTY0MTM1NDM2NTYzNzE5ODg0MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 5334233204f2c8067dfb65e168f76aec52fd1c30eca0b599948f9bc0ddb6345d |
| hovercard-subject-tag | issue:4661871469 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/matplotlib/matplotlib/31899/issue_layout |
| twitter:image | https://opengraph.githubassets.com/631cb3bc451677607d6fd535a84b5a65799c99a472db2e93f87206d3314bb91c/matplotlib/matplotlib/issues/31899 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/631cb3bc451677607d6fd535a84b5a65799c99a472db2e93f87206d3314bb91c/matplotlib/matplotlib/issues/31899 |
| og:image:alt | Bug summary Run the attached code with the qtagg as well as the macosx backends. While the mouse cursor is over the figure, perform the following: Click mouse. Release mouse Hold Option: Click mous... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | iccir |
| hostname | github.com |
| expected-hostname | github.com |
| None | c6353e56e94423c9cd5abde7708a859afa36a0c1203c73749055bf6ee6704cd0 |
| turbo-cache-control | no-preview |
| go-import | github.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git |
| octolytics-dimension-user_id | 215947 |
| octolytics-dimension-user_login | matplotlib |
| octolytics-dimension-repository_id | 1385122 |
| octolytics-dimension-repository_nwo | matplotlib/matplotlib |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1385122 |
| octolytics-dimension-repository_network_root_nwo | matplotlib/matplotlib |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | f59ab1c46b638204e2aea09126d089be5dc773b7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width