Listen and post on focus loss + gained events. Focus events are a little strange in the forte implementation. It's like they have a child listener built in. For example, if DataField D1 in GridField G1 loses focus and that focus loss takes the focus out of grid field G1 then there should be 2 focus loss events fired, that from D1 and also that from G1. However, if D1 loses focus to another data field D2 inside G1, then only D1 should fire a focus loss event, not G1 (as one of it's children has still retained the focus)
There are 2 ways of implementing this. The first is to register a focus change handler on all the children, and process the focus gain / focus loss events for all these children, looking to see if the old child and the new child are both children and fire the appropriate events if they're not. This will result in a lot of focus listeners at higher grid field levels. The other way is to monitor the permanent focus owner in a method similar to the TraverseListener and fire events when this changes. We use the former way, even though it posts obsolete events because it is the cleanest to implement -- using the property change event on the permanent focus owner, you won't necessarily know who the other side of the event is.
There is another issue to consider: When a new child is added to the hierarchy of a container, if that container listens for the focus change events the new field must automatically post these events. We use container listeners to ensure that when the hierarchy changes, the appropriate focus events are registered on the new components, or deregistered on the old components.
Some components automatically post their own focus events -- this class is aware of these and prevents duplicate events being posted.
@author Tim
@since 17/07/2007