🧪 Version 0.2.2 is our alpha release candidate. Please send us bug reports and suggestions!

Sketchingpy

Creative coding and interactive science everywhere for everyone: web, desktop, mobile, Jupyter, and more. Open source!

Reference for on_button_press

Specify callback for when a mouse button is pressed. This is part of the reference section.

Purpose

Register a callback for when a button is pressed, calling a function with the button and mouse. Will pass the Button as argument. Will unregister prior callbacks for on_button_press.

Snippet

Register a simple click callback.
callback = lambda button: print(button.get_name())
sketch.get_mouse().on_button_press(callback)

Parameters

  • callback: The function to invoke when a mouse button or equivalent is pressed.

Examples

Availability

Available for Sketch2DApp and Sketch2DWeb. Note that, on web, right click may be intercepted by the operating system and may not be available to the sketch or may be delayed.

See also