#1
|
|||
|
|||
custom events within classes
Hi, is it possible to register more than one function for listing on a custom event? When pressing the 'e'-button the following code should print out 'B' and 'C'. But only 'C' is printed out. When I swap the two *.enableEvent(EVENT) lines then 'B' is printed out.
Therefore I guess only one function can listen to an event at the same time. Am I right? Code:
import viz class A(object): def __init__(self): pass def enableEvent(self, EventID): viz.callback(EventID,self.doit) def doit(self): pass class B(A): def __init__(self): pass def doit(self): print "B" class C(A): def __init__(self): pass def doit(self): print "C" viz.go() EVENT = viz.getEventID('EVENT') b = B() b.enableEvent(EVENT) c = C() c.enableEvent(EVENT) def sendEvent(): viz.sendEvent(EVENT) vizact.onkeydown('e',sendEvent) |
#2
|
|||
|
|||
Yes, have a look in the documentation under the Reference -> Events -> Event basics section. It contains sample code showing how to use the viz.EventClass for registering multiple objects with an event.
|
#3
|
|||
|
|||
the vizact.onevent function is pritty handy for this too
__________________
Paul Elliott WorldViz LLC |
#4
|
|||
|
|||
Hm, could you illustrate it on my sample code please? I had a look on the event classes but I don't know how to process my own event in class A respectively B and C.
The vizact.onevent documentation is unfortunately to scarce. |
#5
|
|||
|
|||
Code:
class A(object): def __init__(self): pass def enableEvent(self, EventID): vizact.onevent(EventID, lambda : (True,None),self.doit)
__________________
Paul Elliott WorldViz LLC |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Howto debug a custom plugin? | reedev | Plug-in development | 3 | 04-23-2009 02:16 PM |
Adding custom faces | mjabon | Vizard | 2 | 04-01-2009 08:34 PM |
How do I add custom functions to a custom plugin? | reedev | Plug-in development | 7 | 02-01-2009 03:39 AM |
animating custom faces: in search of "open_mouth" morphs | vr_boyko | Vizard | 1 | 09-16-2004 10:30 AM |
Creating Custom Avatar Heads | farshizzo | Vizard | 22 | 09-12-2004 09:23 PM |