WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 05-12-2009, 11:48 AM
Penguin Penguin is offline
Member
 
Join Date: Mar 2009
Posts: 14
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)
Reply With Quote
  #2  
Old 05-12-2009, 12:04 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
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.
Reply With Quote
  #3  
Old 05-12-2009, 12:09 PM
Gladsomebeast Gladsomebeast is offline
Member
 
Join Date: Mar 2005
Location: Isla Vizta, CA
Posts: 397
the vizact.onevent function is pritty handy for this too
__________________
Paul Elliott
WorldViz LLC
Reply With Quote
  #4  
Old 05-12-2009, 02:42 PM
Penguin Penguin is offline
Member
 
Join Date: Mar 2009
Posts: 14
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.
Reply With Quote
  #5  
Old 05-12-2009, 03:10 PM
Gladsomebeast Gladsomebeast is offline
Member
 
Join Date: Mar 2005
Location: Isla Vizta, CA
Posts: 397
Code:
class A(object):
	def __init__(self):
		pass
	
	def enableEvent(self, EventID):
		vizact.onevent(EventID, lambda : (True,None),self.doit)
__________________
Paul Elliott
WorldViz LLC
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

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


All times are GMT -7. The time now is 11:33 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC