8000 Merge pull request #16107 from anntzer/draggableartistpick · matplotlib/matplotlib@fb7cf79 · GitHub
[go: up one dir, main page]

Skip to content

Commit fb7cf79

Browse files
authored
Merge pull request #16107 from anntzer/draggableartistpick
Deprecate DraggableBase.artist_picker.
2 parents f6ccef3 + 25d05ac commit fb7cf79

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

doc/api/next_api_changes/deprecations.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,3 +199,8 @@ The change from "nonpos" to "nonpositive" also affects `~.scale.LogTransform`,
199199

200200
To use *different* bases for the x-axis and y-axis of a `~.Axes.loglog` plot,
201201
use e.g. ``ax.set_xscale("log", base=10); ax.set_yscale("log", base=2)``.
202+
203+
``DraggableBase.artist_picker``
204+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
205+
This method is deprecated. If you previously reimplemented it in a subclass,
206+
set the artist's picker instead with `.Artist.set_picker`.

lib/matplotlib/offsetbox.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1694,11 +1694,7 @@ def update_offset(self, dx, dy):
16941694
the point where the mouse drag started.
16951695
'''
16961696
1697-
Optionally, you may override the following methods::
1698-
1699-
def artist_picker(self, artist, evt):
1700-
'''The picker method that will be used.'''
1701-
return self.ref_artist.contains(evt)
1697+
Optionally, you may override the following method::
17021698
17031699
def finalize_offset(self):
17041700
'''Called when the mouse is released.'''
@@ -1719,7 +1715,18 @@ def __init__(self, ref_artist, use_blit=False):
17191715
c2 = self.canvas.mpl_connect('pick_event', self.on_pick)
17201716
c3 = self.canvas.mpl_connect('button_release_event', self.on_release)
17211717

1722-
ref_artist.set_picker(self.artist_picker)
1718+
if not ref_artist.pickable():
1719+
ref_artist.set_picker(True)
1720+
with cbook._suppress_matplotlib_deprecation_warning():
1721+
if self.artist_picker != DraggableBase.artist_picker.__get__(self):
1722+
overridden_picker = self.artist_picker
1723+
else:
1724+
overridden_picker = None
1725+
if overridden_picker is not None:
1726+
cbook.warn_deprecated(
1727+
"3.3", name="artist_picker", obj_type="method",
1728+
addendum="Directly set the artist's picker if desired.")
1729+
ref_artist.set_picker(overridden_picker)
17231730
self.cids = [c2, c3]
17241731

17251732
def on_motion(self, evt):
@@ -1786,6 +1793,7 @@ def disconnect(self):
17861793
else:
17871794
self.canvas.mpl_disconnect(c1)
17881795

1796+
@cbook.deprecated("3.3", alternative="self.ref_artist.contains")
17891797
def artist_picker(self, artist, evt):
17901798
return self.ref_artist.contains(evt)
17911799

0 commit comments

Comments
 (0)
0