This is essentially what the VB6 IDE does. Once you've named a control, you "bind" an event handler by defining a method like "foo_OnClick"; I've always found that a bit kludgey, but it does work. You can get into trouble, though, if you rename the control after defining a few of these methods.
As I mentioned in another reply, RegID is special, and has additional constraints. It is somewhat like a name, but more like a design contract. It is no different than if you were to bind to a particular method and then later go back and change the name of the method - you've broken the binding.
Freewheeling a bit: in effect, what you're doing is implicitly folding the binding of of events for an object into the addObject call. Why not make that explicit? Maybe something like
self.addObject(dabo.ui.dButton, Caption="Hit me",
onHit=functionObject1,
onMouseOver=functionObject2)
This decouples event binding from widget naming, which is probably a Good Thing.
I like that idea. It would take a bit of work to implement, but it certainly is clean and Pythonic.
You could follow this up by allowing dynamic changing of bindings through something like
aWidget.EventBindings(onThis=thisHandler, onThat=None, ...)
(The "None" says "unbind the event".)
Objects have bindEvent() and unbindEvent() methods that accomplish this.
-- Ed Leafe
-- http://leafe.com
-- http://dabodev.com
···
On Jan 23, 2006, at 8:10 PM, Don Dwiggins wrote: