On 04/18/2011 03:12 PM, Ed Leafe wrote:
>
>       Events don't really 'propagate'; instead, they are sent to the objects 
> to which they are bound. It's more of a publish/subscribe model rather than a 
> broadcast model.
Yes, I see now that I had this all backwards. Nice that you cleared this 
up for me.
>       I believe that is by design (perhaps Paul can chime in). Event bindings 
> are registered with the object that raises the event; you change the handler 
> function if you want a different object to handle the event. In your example, 
> anything that wants to respond to txt1's custom event would have to run the 
> equivalent of:
>
> txt1.bindEvent(MyCustomEvent, self.mySpecificHandler)
>
>       So if you wanted to have the form respond to the event, you have two 
> options:
>
> 1) Have the form register with the textbox:
>       self.txt1.bindEvent(MyCustomEvent, self.onMyCustomEvent)
>
> 2) Have the textbox's Hit event raise the event in the form, and then bind to 
> that:
>       self.bindEvent(MyCustomEvent, self.onMyCustomEvent)
>
>       The way I keep things straight is that "bindEvent" registers the 
> handler function with the object that bindEvent is called on; if that object 
> later receives a raiseEvent() for that particular event, it simply calls the 
> bound handler.
So to propagate a signal down I could either do:
1) Register it with the children (many implications here)
for obj in self.Children:
     obj.bindEvent(MyCustomEvent, obj.onMyCustomEvent)

2) Catch the signal and reraise it for all the children
     for obj in self.Children:
         obj.raiseEvent(MyCustomEvent, evt)

or maybe that should be
     for obj in self.Children:
         obj.raiseEvent(MyCustomEvent, evt.EventData)
since you can't raise an already made event object(?)

> There is no generic way to listen to one class of events no matter which 
> object raises them.
>
>
> -- Ed Leafe
>
Thing is that, if I'm not mistaken again :) , there is behaviour like 
updating a Form that calls update on all it's children, and MouseMove 
that can be intercepted from anywhere. That's what made me believe that 
there was such a thing as propagation, but still couldn't find it in the 
code.

In any event, I think my app can very well live with the normal 
behaviour, maybe even more successfully so.

Nick
_______________________________________________
Post Messages to: [email protected]
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/[email protected]

Reply via email to