Reputation: 3016
I'm struggeling with the SWT Events.
Is there a way to get notified when a Combo
is closed? I need to know when it is closed and the selection didn't changed.
I noticed that there is an event type SWT.Collapse
, but as far as I know this only for TreeItem
s (http://book.javanb.com/swt-the-standard-widget-toolkit/ch01lev1sec3.html)
I would be pleased if someone can give me an hint
Upvotes: 1
Views: 687
Reputation: 36884
You can find the list of available Events
for a given Widget
on the Javadoc page. The Event
s for Combo
are:
Events:
DefaultSelection, Modify, Selection, Verify, OrientationChange
If you are just looking for a way to find out if a new item was selected, just listen for SWT.Selection
and compare it to the last selected item. SWT.Selection
is only called when an item actually is selected, not if the Combo
is opened and then closed by loosing the focus:
combo.addListener(SWT.Selection, new Listener()
{
@Override
public void handleEvent(Event arg0)
{
String currentSelection = combo.getItem(combo.getSelectionIndex());
if(currentSelection.equals(oldSelection))
{
// Same item selected
}
else
{
// Different item selected
}
oldSelection = currentSelection;
}
});
Upvotes: 2