From: Kevin A. <al...@se...> - 2006-07-04 19:10:03
|
On Jul 4, 2006, at 10:43 AM, Brad Allen wrote: > > At 12:24 AM -0700 7/4/06, Steve Freitas wrote: >> Ah ha! That'd be on_loseFocus(). >> >> Heh, thanks for such a nice framework. > > There is also on_closeField; here is how I do it: > > def on_closeField (self, event): > component = event.target > > This handler usually goes into a custom event mixin class which > all my Background and PageBackground classes inherit from. > > I have encountered one problem with this approach, though. > If the user closes the window while the cursor is still in one > of the fields, that field never fires on_closeField. Using > on_loseFocus never occurred to me; I'll try it and see if > that eliminates the problem. > > For a workaround, I handle on_close in my event mixin class, > and check each field for the given window to see if it differs > from the associated 'model' object. Sadly, when an application is exiting is troublesome time for event dispatch due to race conditions and wanting to avoid crashes due to referencing C++ objects that have already been destroyed. In addition, the order of events is probably still slightly different on the three platforms, so extensive testing is needed if you want to work everywhere. There is a testevents sample application that you can muck around with to get a better feel for what events happens when. Due to how events are bound and unbound at application startup and exit, the message watcher doesn't work very well for these special cases so you're best off just printing to the console. ka |