Retrieve native mouse event object.


def setup():
    py5.size(200, 200, py5.P2D)

def draw():
    py5.square(py5.random(py5.width), py5.random(py5.height), 10)

def mouse_clicked(e):
    native_event = e.get_native()
    if native_event != None:
        py5.println(native_event.getX(), native_event.getY())


Retrieve native mouse event object. The returned object will be a Java object and its type can vary based on the renderer used by the Sketch and the operating system the Sketch is run on. Sometimes the native object can be used to access functionality not otherwise available through Processing or py5.

Be aware that it is possible for the native event object to be None, such as when interacting with a Sketch through py5_tools.sketch_portal().

Underlying Processing method: getNative


get_native() -> Any

Updated on September 01, 2022 16:36:02pm UTC