base.accept("arrow_left", setKey, ["left",1])
i dont understand this line of code…
base.accept("arrow_left", setKey, ["left",1])
i dont understand this line of code…
base.accept("arrow_left", setKey, ["left",1])
if the “arrow-left” key (←) is presed the function “setKey” is called, with (“left”, 1) as parameter.
pressing the key does the same as executing
setKey("left",1)
there is nothing wrong with it. instead of setKey you can call pretty much every function you defined in your code.
I got a bit confused with the [] thingy.
Where is setKey defined? I tried base.setKey , thats not it
somewhere in your code there should be the line
def setKey( ....
if you copied the accept line out of a sample. check the rest of the sample for the setKey function.
i just looked at the definition of accept DirectObject
def accept(self, event, method, extraArgs=[]):
return messenger.accept(event, self, method, extraArgs, 1)
^ and found this revelation. You don’t need base or any DirectObjects to catch events its all messanger - which makes far more sense.
Wow, that was stupid…
Thanks, everything works now
treeform, you mean…?
i am in my own lala land sorry.
from DirectObject.py
# Wrapper functions to have a cleaner, more object oriented approach to
# the messenger functionality.
for the record:
messenger.accept() uses DirectObjects as holders for identification of event listeners (useful for debugging).
the last argument of messenger.accept() is the persistent flag. DirectObject has two methods for that:
DO.accept() # flag 1
DO.acceptOnce() # flag 0
use the latter for one-time keys