Vizard 7 » Command Index » Vizard modules » viz » <viz:mouse>.getState
7.7

<viz:mouse>.getState

This command returns the current state of the mouse buttons

<viz:mouse>.getState(  
immediate = False  
)  
immediate = False
If True, Vizard will immediately query the mouse instead of using the cached value.

Remarks

Use this command at any time to check which mouse buttons are down.

Return Value

An integer which hold the state of the mouse buttons.

Example

state = viz.mouse.getState()
if state & viz. MOUSEBUTTON_LEFT:
    print('left button down')
if state & viz. MOUSEBUTTON_RIGHT:
    print('right button down')
if state & viz. MOUSEBUTTON_MIDDLE:
    print('middle button down')