Skip to content

Remove tk button swap logic on macOS - #32187

Open
iccir wants to merge 1 commit into
matplotlib:mainfrom
iccir:tk-macos-button-swap
Open

Remove tk button swap logic on macOS#32187
iccir wants to merge 1 commit into
matplotlib:mainfrom
iccir:tk-macos-button-swap

Conversation

@iccir

@iccir iccir commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

PR summary

During testing, I noticed that the middle and right mouse buttons are reversed under macOS when running under tk.

The original 2/3 button swap logic is 22 years old.

tk fixed this 6 years ago.

Test File

import matplotlib.pyplot as plt

def on_press(event):
    print(f"Press: button={event.button}")

def on_release(event):
    print(f"Release: button={event.button}")

def on_move(event):
    if event.key == 'shift':
        print(f"Buttons: {sorted(event.buttons)}")

fig, ax = plt.subplots()
fig.canvas.mpl_connect("button_press_event", on_press)
fig.canvas.mpl_connect("button_release_event", on_release)
fig.canvas.mpl_connect("motion_notify_event", on_move)

plt.show()

AI Disclosure

No AI.

PR quality check

  • Use an expressive title, e.g. "Fix title font property precedence"
  • New and changed code is tested
  • [N/A] Plotting related features are demonstrated in an example
  • [N/A] New features and API changes have release notes
  • [N/A] Documentation complies with general and docstring guidelines

@QuLogic
QuLogic requested a review from greglucas August 15, 2026 05:51

@QuLogic QuLogic left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code-wise, this makes sense. I suppose someone on a mac should test it out.

@QuLogic
QuLogic requested review from ksunden and tacaswell August 15, 2026 05:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants