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

Skip to content

Commit 963506f

Browse files
committed
Merge pull request #1088 from dhyams/text_contains_based_on_master
For a text artist, if it has a _bbox_patch associated with it, the contains test should reflect this.
2 parents 0b64cc1 + 834f4cb commit 963506f

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

lib/matplotlib/text.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,16 @@ def contains(self,mouseevent):
211211

212212
x, y = mouseevent.x, mouseevent.y
213213
inside = (l <= x <= r and b <= y <= t)
214-
return inside, {}
214+
cattr = {}
215+
216+
# if the text has a surrounding patch, also check containment for it,
217+
# and merge the results with the results for the text.
218+
if self._bbox_patch:
219+
patch_inside, patch_cattr = self._bbox_patch.contains(mouseevent)
220+
inside = inside or patch_inside
221+
cattr["bbox_patch"] = patch_cattr
222+
223+
return inside, cattr
215224

216225
def _get_xy_display(self):
217226
'get the (possibly unit converted) transformed x, y in display coords'

0 commit comments

Comments
 (0)