ComboBox selection change listener issue [message #1004638] |
Wed, 23 January 2013 15:23 |
Levente Mising name Messages: 3 Registered: December 2010 |
Junior Member |
|
|
Hello,
I created a simple ComboBox with the values A, B, C, D, E in it.
I have also added a ModifyListener and an ISelectionChangeListener to it.
To my surprise, these two listeners were notified even if the selection did not actually change in the ComboBox. For example, assuming that the current selection was B, if I opened up the ComboBox and selected B again, both of the listeners were called back!
Is there any way to ensure that the listeners are only notified when the content of the ComboBox actually changes? The ComboBox was created with the SWT.DROP_DOWN style because I wanted to allow the user to edit the combo.
Best regards,
Levente
|
|
|
Re: ComboBox selection change listener issue [message #1005703 is a reply to message #1004638] |
Mon, 28 January 2013 10:49 |
John Steele Messages: 50 Registered: January 2010 |
Member |
|
|
Dude, come on, I just tested it, and it only notifies the listener when the selection index changes (i.e., the selection listener does not get notified if you select the same index within the Combo).
final Combo combo = new Combo(parent, SWT.DROP_DOWN);
combo.setItems(new String [] {"Test1", "Test2", "Test3"});
combo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
System.out.println("Selection: " + combo.getItem(combo.getSelectionIndex()));
}
});
BTW, I'm using "Combo" not "ComboBox". I don't know where you're getting the "ComboBox" widget from.
Levente Mising name wrote on Wed, 23 January 2013 10:23Hello,
I created a simple ComboBox with the values A, B, C, D, E in it.
I have also added a ModifyListener and an ISelectionChangeListener to it.
To my surprise, these two listeners were notified even if the selection did not actually change in the ComboBox. For example, assuming that the current selection was B, if I opened up the ComboBox and selected B again, both of the listeners were called back!
Is there any way to ensure that the listeners are only notified when the content of the ComboBox actually changes? The ComboBox was created with the SWT.DROP_DOWN style because I wanted to allow the user to edit the combo.
Best regards,
Levente
|
|
|
Powered by
FUDForum. Page generated in 0.02279 seconds