Skip to content

Commit fcb6296

Browse files
authored
Merge pull request #17480 from anntzer/rsa
FIX: Regenerate background when RectangleSelector active-flag is set back on.
2 parents 3be0c3b + 5cf1fa0 commit fcb6296

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

lib/matplotlib/widgets.py

+14-1
Original file line numberDiff line numberDiff line change
@@ -1456,8 +1456,21 @@ def update_background(self, event):
14561456
"""Force an update of the background."""
14571457
# If you add a call to `ignore` here, you'll want to check edge case:
14581458
# `release` can call a draw event even when `ignore` is True.
1459-
if self.useblit:
1459+
if not self.useblit:
1460+
return
1461+
# Make sure that widget artists don't get accidentally included in the
1462+
# background, by re-rendering the background if needed (and then
1463+
# re-re-rendering the canvas with the visible widget artists).
1464+
needs_redraw = any(artist.get_visible() for artist in self.artists)
1465+
with ExitStack() as stack:
1466+
if needs_redraw:
1467+
for artist in self.artists:
1468+
stack.callback(artist.set_visible, artist.get_visible())
1469+
artist.set_visible(False)
1470+
self.canvas.draw()
14601471
self.background = self.canvas.copy_from_bbox(self.ax.bbox)
1472+
if needs_redraw:
1473+
self.update()
14611474

14621475
def connect_default_events(self):
14631476
"""Connect the major canvas events to methods."""

0 commit comments

Comments
 (0)