Page 1 of 1

Lost focus for a group of controls

Posted: Fri Aug 07, 2009 2:55 pm
by ConvertFromOldNGs
by Torrie >> Tue, 18 Apr 2006 1:58:02 GMT

Does anyone know an easy way to detect that the focus has been lost from a group of controls. For example if there are 3 "interactive" controls in a group box on a form and you want to detect when the focus is lost from all of the child controls in the group box, eg the user pressed tab from the last control in the group box and a control outside the group box has the focus.

There doesn't appear to be a lost focus event that I can use on a frame or group box and I'd rather not use a lost focus event on the form as this will fire for all controls on the form. I know I can code this into the lost focus event on the controls concerned and check to see if another control has received focus but wondered if there was another way?

Thanks Torrie

Re: Lost focus for a group of controls

Posted: Fri Aug 07, 2009 2:55 pm
by ConvertFromOldNGs
by Patwos >> Tue, 18 Apr 2006 6:32:23 GMT

One possibility could be to use setEventMapping in the Form::load event to map the lostFocus for all three controls to the one method. This would avoid the need to repeat the same code in all three lostFocus methods or put a one liner into each lostFocus event that calls a common method. Unfortunately this event will still fire for each control as it loses focus, possibly to one of the other child controls, rather than when the whole group loses focus.

However, I'd ask the question do you really need the lostFocus? If your intended audience for the system will potentially be connecting over a slow link, lostFocus events can get in the way of fast data entry to the extent that they are more of an annoyance than a convenience.

I've seen a number of systems where the lostFocus was implemented in ways that didn't really add enough benefit to the application behaviour versus the annoyance factor of the unavoidable delays while those lostFocus events were processing - particularly if the AppServer is already quite busy processing other work at that time.

Hope that helps,
Pat.

Re: Lost focus for a group of controls

Posted: Fri Aug 07, 2009 2:55 pm
by ConvertFromOldNGs
by Pam >> Wed, 3 May 2006 7:18:10 GMT

I check in the lostFocus for all 3 controls that app.activeControl.parent <> grpBox.