views:

185

answers:

1

Hello Experts

Our Control
I have a Custom SWT implementation of a Combobox/DropDownList.
This is implemented as a Composite containing a Text and a Button.
When the list is showed, we use a List control that is placed on top of everything and positioned at the Text and Button.

This works as expected.

The Problem
But we are having issues with focusLost and focusGained.
Ultimately i would like for any external component to get a focusGained when any part of the custom gains focus and only throw a focusLost when focus is lost from any part and no other part gains focus.

I would like to avoid handling focusLost and focusGained when focus is merely moved from the text to the button inside my custom control.

Do anyone know of an API to know, during focusLost, where focus will land?
Do anyone have an idea how to implement this in any way?

A: 

Simply put, there is no way of determining which control has gained focus from within focusLost().

I would suggest adding FocusListeners to each control in your composite (you can automate this by iterating through getChildren()) and keep track of the focus object using a common field.

In other words, there is unfortunately no API function that does this for you.

Paul Lammertsma