OnClick¶
- class vtkplotlib.interactive.OnClick[source]¶
OnClickprovides a higher-level means to attach callbacks to mouse click events without unintentionally also catching mouse click-and-drag events.- Parameters
button (str) – Any of Middle, TDx, Fifth, Right, Fourth, Left (case-insensitive).
style (
vtkplotlib.figure, vtkInteractorStyle) – The figure or vtkInteractorStyle to attach to, writeable.on_click (callable taking a
pickas an argument, None) – Method to call when a click happens, writeable, set to None to disable, defaults toprint().mouse_shift_tolerance (int) – The maximum mouse movement in pixels between mouse-down and mouse-up allowed for a click to not be counted as a click-and-drag, writeable, defaults to
2.pick (pick) – Set a custom
pick(), writeable, defaults to creating its own on initialisation.
All parameters are available as attributes with the same name. Of these, parameters labelled writeable can be set or altered later.
Note
Forth and Fifth button names require
VTK>=8.0.Usage of
OnClick()differs from that offig.style.AddObserver(event_name, callback)in the following ways.Callbacks take a single argument pick.
The calling of
call_super_callbackis automatic.If using a user-supplied pick, then
pick.update()is called automatically before passing it to the callback.
See the example from pick.from_ for a usage demonstration.