SWT editable Combo - select index when text box is not empty

390 Views Asked by At

Using SWT editable Combo, I'm trying to make my program select a specific index.

I see the following behaviour: if the index before I go and try to change it is other than -1 - the select works just fine. But if the index is -1, my trying to select doesn't work. The combo text box gets the new value but whenn trying to get currentSelectionIndex I get -1 and not 0.

The code I'm using is:

if (cmbModel.getSelectionIndex() == -1) {                 
     cmbModel.select(0);
}

UPDATE: After more investigaion I see that if the textbox is empty when i try to set the current index - it works. If user writes something in the combos' text box - the select doesn't work.

0

There are 0 best solutions below