Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Bug]: macosx backend takes mouse events even if there is no window. #31500

@cinsk

Description

@cinsk

Bug summary

Although matplotlib macosx window was closed (not visible on the screen), it still eat up mouse click event on the area it previously positioned. This problem recently appeared as I upgraded matplotlib to 3.10.8. (Unfortunately, I don't remember which version I used before)

Code for reproduction

import matplotlib.pyplot as plt
plt.pie([1])
plt.show()

# 1. close the window by pressing 'q'.
# 2. If you never clicked other area, Python process will hold the focus of the Mac.
# 3. click the mouse on other application or Mac Desktop where the point is in the same position within the previous matplotlib window.
# 4. your mouse click event will not pass through to the window under the point, but Python process will eat up the event
# 5. If you switch the focus to the target application using CMD-TAB, you can pass the mouse event, but if you give the focus to the Python process again, the same problem still exists.

Actual outcome

Mac screen or other application window cannot receive mouse click event if the area was previously occupied by matplotlib window.

Expected outcome

Mouse click event should pass to the (other) application window or to Mac dekstop.
(matplotlib should not eat up mouse click event if there is no visible window of it)

Additional information

No response

Operating system

Mac Tahoe 26.1

Matplotlib Version

3.10.8

Matplotlib Backend

macosx

Python version

3.14.2

Jupyter version

No response

Installation

pip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions