Thread: vhil module
View Single Post
  #2  
Old 01-27-2005, 09:42 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi,

1) Yes, your callback will overwrite any callback set by the user

2) Well, if you register a timer callback then it will overwrite the users timer callback, so they won't get any timer events.

Using an Event Class is the proper way to handle events in separate modules. For example, if you wanted your module to handle timer and keydown events you would do the following:
Code:
import viz

#Create class that inherits from viz.EventClass
class _VHILEvent(viz.EventClass):
	def __init__(self):
		viz.EventClass.__init__(self)
		
		#Register callback for this class instance
		self.callback(viz.TIMER_EVENT,self.mytimer)
		self.callback(viz.KEYDOWN_EVENT,self.mykeydown)
		
		#Start a timer that belongs to this instance
		self.starttimer(0,0.1,viz.FOREVER)
		
	def mytimer(self,num):
		pass
		
	def mykeydown(self,key):
		pass
		
#Create an instance of _VHILEvent class
_VE = _VHILEvent()
Reply With Quote