Paul McNett wrote: > Ed Leafe wrote: >> On Jun 13, 2007, at 10:57 AM, johnf wrote: >> >>> When I design a class and want to bind an Event (to the class) do I >>> bind it as >>> self.Form.bindEvent(dEvent,????, _function) since I don't have an >>> instance of >>> the class? IOW how can I bind an event to my class from within >>> the class? >> I'm not sure I understand what you mean. First, if the event is >> something that is raised by your class, you can't bind the form to >> it: a double-click in a grid is not sent to the form; it's sent to >> the grid. So what I think you want to do is bind an event in your >> class to a pre-determined form method. If that is the case, and you >> don't mind linking the classes like that, you would probably do >> something like this in your class: >> >> def initEvents(self): >> if self.Form and hasattr(self.Form, "someHandler"): >> self.bindEvent(dEvents.SomeEvent, self.Form.someHandler) >> >> This will bind 'SomeEvent' (whatever you desire) to a method on the >> form called 'someHandler', as long as that method exists. > > Or, from the form (which knows it has the grid): > > class MyForm(...): > def afterInit(self): > self.grid = dabo.ui.dGrid(self,...) > self.grid.bindEvent(dEvents.Whatever, self.onWhatever) > > def onWhatever(self, evt): > # called when the grid's Whatever event happens. >
Ed and Paul, my question about evt-binding was because i wasn't sure about all implications of the ways you can use to bind to events. Now that these cleared up i think that this would be something worth adding as some small examples to the wiki. Should i add a ticket for this? Uwe _______________________________________________ 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/dabo-users/[EMAIL PROTECTED]
