Vizard 8 » Command Index » Vizard objects » node3d » <node3d:canvas>.sendMouseButtonEvent
8.0

<node3d:canvas>.sendMouseButtonEvent

Simulate a mouse button event on the canvas

<node3d:canvas>.sendMouseButtonEvent(  
button  
state  
)  
button
The mouse button to simulate being pressed/released. Can be one of the following buttons:

viz.MOUSEBUTTON_LEFT
viz.MOUSEBUTTON_MIDDLE
viz.MOUSEBUTTON_RIGHT
state
The mouse button state to simulate. Can be one of the following modes:

viz.DOWN
viz.UP

Remarks

This command can be used to simulate a mouse button press/release on the canvas. This can be useful when using an alternate input method to interact with the canvas (e.g. joystick, wand). The current cursor position of the canvas is used as the mouse button event position.

Return Value

A combination of the following event action flags:

Flag

Description

viz.EVENT_STOP

Stop the event from being passed on to remaining handlers.

viz.EVENT_PREVENT_DEFAULT

Prevent any default behavior the application would perform for the event.

Example

def CanvasButtonTask():

    while True:

        # Wait for sensor button 1 to be pressed
        yield viztask.waitSensorDown(sensor, 1)

        # Simulate mouse button press on canvas
        canvas.sendMouseButtonEvent(viz.MOUSEBUTTON_LEFT, viz.DOWN)

        # Wait for sensor button 1 to be released
        yield viztask.waitSensorUp(sensor, 1)

        # Simulate mouse button release on canvas
        canvas.sendMouseButtonEvent(viz.MOUSEBUTTON_LEFT, viz.UP)

viztask.schedule(CanvasButtonTask())

See also

<node3d:canvas>.getMouseStyle
<node3d:canvas>.setMouseStyle