To my understanding, when you call raiseEvent from somewhere, you just 
release it to the wild for any listening handlers to act on it.
Well, not exactly, as http://wiki.dabodev.com/Events suggests that an 
event propagates only to the children of the object that raised them.

But I'm stuck for some hours now, and I can't seem to be able to listen 
for an event, except when I'm raising it from the same object that listens.
None of the children of the raising object get the event.

My sample code is at the bottom:

On this example, when a TextBox raises the Event, it responds to it.
When the Form raises it, it only gets the Event itself. I was expecting 
the TextBoxes to get it too.
Finally, when I raise the Event from the Application, none of it's 
children get it.

I've run many iterations but nothing seems to matter. And it also 
happens with regular (not custom) events as far as I tested.

So, should I be doing something more here, or is it that I've completely 
misunderstood the event model?

Nick




(if the formatting breaks just look here http://pastebin.com/NfkgFCk5 )
-----------------------------------------------
import dabo
dabo.ui.loadUI('wx')

class MyCustomEvent(dabo.dEvents.dEvent): pass

class MyTextBox(dabo.ui.dTextBox):
     def initEvents(self):
         self.bindEvent(MyCustomEvent, self.onMyCustomEvent)

     def onMyCustomEvent(self, evt):
         print self.RegID, evt.EventData['message']

     def onHit(self, evt):
         self.raiseEvent(MyCustomEvent, message='Raised from self')
         self.Form.raiseEvent(MyCustomEvent, message='Raised from Form')
         self.Application.raiseEvent(MyCustomEvent, message='Raised from 
App')

class MainForm(dabo.ui.dForm):
     def afterInit(self):
         txt1 = MyTextBox(self, RegID='txt1')
         txt2 = MyTextBox(self, RegID='txt2')
         self.Sizer.append1x(txt1)
         self.Sizer.append1x(txt2)
         self.Sizer.layout()

     def initEvents(self):
         self.bindEvent(MyCustomEvent, self.onMyCustomEvent)

     def onMyCustomEvent(self, evt):
         print "Form", evt.EventData['message']


app = dabo.dApp()
app.MainFormClass = MainForm
app.start()
-------------------------------------------------------

_______________________________________________
Post Messages to: Dabo-users@leafe.com
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/4dabae5c.5080...@otenet.gr

Reply via email to