MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / _clicked

Method _clicked

lib/matplotlib/widgets.py:1195–1205  ·  view source on GitHub ↗
(self, event)

Source from the content-addressed store, hash-verified

1193
1194 @_call_with_reparented_event
1195 def _clicked(self, event):
1196 if self.ignore(event) or event.button != 1 or not self.ax.contains(event)[0]:
1197 return
1198 idxs = [ # Indices of frames and of texts that contain the event.
1199 *self._buttons.contains(event)[1]["ind"],
1200 *[i for i, text in enumerate(self.labels) if text.contains(event)[0]]]
1201 if idxs:
1202 coords = self._buttons.get_offset_transform().transform(
1203 self._buttons.get_offsets())
1204 self.set_active( # Closest index, only looking in idxs.
1205 idxs[(((event.x, event.y) - coords[idxs]) ** 2).sum(-1).argmin()])
1206
1207 def on_clicked(self, func):
1208 """

Callers

nothing calls this directly

Calls 6

get_offset_transformMethod · 0.80
get_offsetsMethod · 0.80
ignoreMethod · 0.45
containsMethod · 0.45
transformMethod · 0.45
set_activeMethod · 0.45

Tested by

no test coverage detected