From: Steve F. <sf...@ih...> - 2006-07-04 06:57:17
|
Hi, I've got to put together a number of pages with a lot of text fields, the contents of which need to be saved as soon as they're changed, and I'd like to avoid writing a lot of boilerplate on_textFieldName_loseFocus() events. So I'd like to modify the event dispatch so that whenever a text field loses focus, PythonCard will call a single, particular function within the page's object with that event, such as handleAllTextFieldsLosingFocus(self, event). Then at that point I can inspect the field using event.target and do my saving. Is there a better way of doing this then mucking around with the event dispatch system? Otherwise I'd guess subclassing Scriptable is probably the right direction? Any help would be appreciated. Thanks. Steve |
From: Steve F. <sf...@ih...> - 2006-07-04 07:24:06
|
Ah ha! That'd be on_loseFocus(). Heh, thanks for such a nice framework. Steve On Mon, 2006-07-03 at 23:57 -0700, Steve Freitas wrote: > Hi, > > I've got to put together a number of pages with a lot of text fields, > the contents of which need to be saved as soon as they're changed, and > I'd like to avoid writing a lot of boilerplate > on_textFieldName_loseFocus() events. > > So I'd like to modify the event dispatch so that whenever a text field > loses focus, PythonCard will call a single, particular function within > the page's object with that event, such as > handleAllTextFieldsLosingFocus(self, event). Then at that point I can > inspect the field using event.target and do my saving. > > Is there a better way of doing this then mucking around with the event > dispatch system? Otherwise I'd guess subclassing Scriptable is probably > the right direction? > > Any help would be appreciated. Thanks. > > Steve > > > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > Pythoncard-users mailing list > Pyt...@li... > https://lists.sourceforge.net/lists/listinfo/pythoncard-users |
From: Brad A. <bra...@ma...> - 2006-07-04 17:43:25
|
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. |
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 |
From: Steve F. <sf...@ih...> - 2006-07-04 22:04:30
|
On Tue, 2006-07-04 at 12:43 -0500, Brad Allen wrote: > 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. Thanks for the tips. on_loseFocus does get called when the window closes, at least for me under Linux. Steve |