Vizard 7 » Command Index » Vizard modules » vizact » <vizact>.onpick
7.4

<vizact>.onpick

Perform an action when an object is picked.

<vizact>.onpick(  
node  
func  
*args  
)  
node
The node3d object to handle
func
The function to call when the node3d object is picked with the left mouse button
*args
The arguments to pass to the function.

Remarks

This will call the specified function with the specified arguments whenever the specified object is picked. Picking an object involves left clicking on it.

Return Value

A vizact.EventFunction object with the following methods:

Method

Description

<event>.setEnabled(val)

Enable/Disable the event function. The associated function will not be called while the event function is disabled. viz.TOGGLE can be used to toggle the state. Event functions are initially enabled.

<event>.getEnabled()

Get the enabled state of the event function.

<event>.remove()

Permanently unregister the event function.

Example

PickAction = vizact.sequence(vizact.sizeTo([2,2,2],speed=16),vizact.sizeTo([1,1,1],speed=8))
for x in range(5):
    ball = viz.add('ball.wrl',pos=[x-2,1.8,7])
    vizact.onpick(ball,ball.runAction,PickAction)
viz.clearcolor(viz.GRAY)
viz.mouse(viz.OFF)

See also

<vizact>.onmousedown
<vizact>.onmouseup
<vizact>.onwheeldown
<vizact>.onwheelup
<vizact>.whilemousedown