unset onkeydown for a key?
Hi all
Is there a way to unset the onkeydown for a key once you already assigned it an action? Thanks Josh |
You can use:
Code:
viz.callback(viz.KEYDOWN_EVENT,None) Code:
vizact.onkeydown(key, None) |
Thanks so far...
The space bar should only be pressed once in my experiment: vizact.onkeydown(' ', play_first_joke) As soon as it's been pressed, it shouldn't invode the play_first_joke method anymore. vizact.onkeydown(' ', None) ...gives the following error: Code:
Traceback (most recent call last): |
After searching in the documentation I found the following:
Code:
|
Thank you. But I don't know how exactly I can use this now... I'm sorry, I'm absolutely new to Python and to the theories that stand behind events in WorldViz...
|
Whenever you register a function with vizact.onkeydown a reference is made in memory between the keystroke and the function. What you wish to achieve is to break that reference. A way to do that, have your program memorize that reference as a variable and then do some operation on that variable, in this case: removeEvent.
Take for example: Code:
def initialiseProgram(): |
Thanks, that helps a lot. :-)
|
All times are GMT -7. The time now is 02:18 AM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC