8000 Sync ToolManager status message to toolbar's. · matplotlib/matplotlib@9ac3474 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9ac3474

Browse files
committed
Sync ToolManager status message to toolbar's.
They are almost the same code, but fell a little out of sync, with the toolbar using two lines in some cases, while ToolManager used the old single-line message.
1 parent 67aafa9 commit 9ac3474

File tree

2 files changed

+14
-26
lines changed

2 files changed

+14
-26
lines changed

lib/matplotlib/backend_bases.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2984,11 +2984,9 @@ def _wait_cursor_for_draw_cm(self):
29842984
else:
29852985
yield
29862986

2987-
def mouse_move(self, event):
2988-
self._update_cursor(event)
2989-
2987+
@staticmethod
2988+
def _mouse_event_to_message(event):
29902989
if event.inaxes and event.inaxes.get_navigate():
2991-
29922990
try:
29932991
s = event.inaxes.format_coord(event.xdata, event.ydata)
29942992
except (ValueError, OverflowError):
@@ -3005,7 +3003,14 @@ def mouse_move(self, event):
30053003
data_str = a.format_cursor_data(data).rstrip()
30063004
if data_str:
30073005
s = s + '\n' + data_str
3008-
self.set_message(s)
3006+
return s
3007+
3008+
def mouse_move(self, event):
3009+
self._update_cursor(event)
3010+
3011+
s = self._mouse_event_to_message(event)
3012+
if s is not None:
3013+
self.set_message(s)
30093014
else:
30103015
self.set_message(self.mode)
30113016

lib/matplotlib/backend_tools.py

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -339,27 +339,10 @@ def send_message(self, event):
339339
if self.toolmanager.messagelock.locked():
340340
return
341341

342-
message = ' '
343-
344-
if event.inaxes and event.inaxes.get_navigate():
345-
try:
346-
s = event.inaxes.format_coord(event.xdata, event.ydata)
347-
except (ValueError, OverflowError):
348-
pass
349-
else:
350-
artists = [a for a in event.inaxes._mouseover_set
351-
if a.contains(event) and a.get_visible()]
352-
353-
if artists:
354-
a = cbook._topmost_artist(artists)
355-
if a is not event.inaxes.patch:
356-
data = a.get_cursor_data(event)
357-
if data is not None:
358-
data_str = a.format_cursor_data(data)
359-
if data_str is not None:
360-
s = s + ' ' + data_str
361-
362-
message = s
342+
from matplotlib.backend_bases import NavigationToolbar2
343+
message = NavigationToolbar2._mouse_event_to_message(event)
344+
if message is None:
345+
message = ' '
363346
self.toolmanager.message_event(message, self)
364347

365348

0 commit comments

Comments
 (0)
0