Vizard 8 » Command Index » Vizard modules » viz » <viz>.callback
8.0

<viz>.callback

This command registers a callback function. This is required to handle events

<viz>.callback(  
event  
function  
mask = viz.MASTER  
priority = 0  
)  
event
Specifies the type of event
function
Specifies the function to be called (i.e., function pointer). If the value is 0, then the callback will be disabled.
mask = viz.MASTER
When clustering is active, this mask specifies the cluster clients to register the callback for. When a callback is triggered, the <viz:cluster>.getClient command can be used to determine which client triggered the event.

Callbacks for cluster clients can be registered only for the following events:

viz.KEYDOWN_EVENT
viz.KEYUP_EVENT
viz.KEY_CHAR_EVENT
viz.MOUSEDOWN_EVENT
viz.MOUSEUP_EVENT
viz.DOUBLE_CLICK_EVENT
viz.MOUSEWHEEL_EVENT
viz.MOUSE_MOVE_EVENT
viz.WINDOW_SIZE_EVENT
viz.BUTTON_EVENT
viz.SLIDER_EVENT
viz.LIST_EVENT
priority = 0
The priority to register the function with

Remarks

Use this command to register a function to handle a particular type of event. When the registered type of event occurs during the simulation cycle, Vizard will call the desired function with certain state parameters depending on the type of event.

This command will register the callback with the global event class. This means only one function can be registered per event. If you want to register multiple functions per event then you need can use multiple instances viz.EventClass to handle the event.

Return Value

None

Example

# Your function definition here
def HandleKeyboard(key):
     print(key)
viz.callback(viz.KEYDOWN_EVENT, HandleKeyboard)

See also

<viz>.starttimer
<viz>.killtimer