i have a DirectButton. if i rollover it, an event is fired.
how can i recognise this event, and if it is fired, do something other (like creating another button, image,…)?
i know there is messenger.toggleVerbose() to get all events happening, but how can i check “enter-pg0” (for rollover-buttonframe-0 i think) is happening, and how can i then fire up other functions?
sorry for my bad english…
now i got this working with e.g. “accept(‘mouse1’,self.doit)”.
but when i set it to “accept(‘enter-pg0’,self.doit)”, i get some errors:
File "D:\work\aexp\tests\testerei\src\root\example.py", line 104, in ?
run()
File "C:\Panda3D-1.4.2\direct\src\showbase\ShowBase.py", line 2176, in run
self.taskMgr.run()
File "C:\Panda3D-1.4.2\direct\src\task\Task.py", line 930, in run
self.step()
File "C:\Panda3D-1.4.2\direct\src\task\Task.py", line 862, in step
self.__stepThroughList(taskPriList)
File "C:\Panda3D-1.4.2\direct\src\task\Task.py", line 764, in __stepThroughList
ret = self.__executeTask(task)
File "C:\Panda3D-1.4.2\direct\src\task\Task.py", line 684, in __executeTask
ret = task(*task.extraArgs)
File "C:\Panda3D-1.4.2\direct\src\showbase\EventManager.py", line 47, in eventLoopTask
self.doEvents()
File "C:\Panda3D-1.4.2\direct\src\showbase\EventManager.py", line 41, in doEvents
self.processEvent(self.eventQueue.dequeueEvent())
File "C:\Panda3D-1.4.2\direct\src\showbase\EventManager.py", line 98, in processEvent
messenger.send(eventName, paramList)
File "C:\Panda3D-1.4.2\direct\src\showbase\Messenger.py", line 240, in send
method (*(extraArgs + sentArgs))
TypeError: doit() takes exactly 1 argument (2 given)
It means, that ‘enter-pg0’ is trying to pass an argument to your function self.doit, while it doesnt take any arguments.
Define your function like this:
def doit(self,arg):
#do with 'arg' whatever you want
When you create a DirectButton, you simply pass any function you like to its command= keyword parameter. This function will be called when the button is clicked.
For a more advanced feature, with any DirectGui object, you can use the DirectGui bind() method to associate functions with esoteric mouse operations. See this thread for more info on that.