Open topic with navigation
<vizact>.onevent
Registers a function to handle the specified event
<vizact>.onevent( |
|
event |
callback |
func |
*args |
) |
|
callback
Callback that will take event arguments and return a 2 item tuple. The first item can be True or False, and specifies whether the vizact event should be triggered. The second item specifies the value to pass to the vizact callback. Use None if no value should be passed.
func
The function to call when the key is pressed
*args
The arguments to pass to the function
Remarks
This command will call the specified function when the specified event is triggered and the specified callback returns True.
Return Value
A
vizact.EventFunction object with the following methods:
<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
def spacebar():
print('spacebar pressed')
vizact.onevent(viz.KEYDOWN_EVENT, lambda k: (k==' ',None),spacebar)
See also