Bug 4942

Summary: Combo selection index should move when upper item removed (1GLGA41)
Product: [Eclipse Project] Platform Reporter: David Whiteman <dlwhiteman>
Component: SWTAssignee: Silenio Quarti <Silenio_Quarti>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P2    
Version: 2.0   
Target Milestone: ---   
Hardware: PC   
OS: QNX-Photon   
Whiteboard:

Description David Whiteman CLA 2001-10-12 14:30:46 EDT
PRODUCT VERSION:
	SWT 2.003 Photon

DESCRIPTION:

	DLW (10/11/2001 5:05:03 PM):
		When an item is removed from a Combo widget, and an item 
		is already selected farther down in the list, the selection
		index should be adjusted to correspond with the item that
		moved up in the list.

		In the following example, the selectionIndex should be 1 
		after item 0 is removed, since the previously selected 
		item moved up from location 2 to location 1 in the list.

--- cut here ----------

import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.layout.*;

//-------------------------------------------------------------------
//
//-------------------------------------------------------------------
public class PR_1GLGA41 {
	private Display  display;
	private Shell    shell;
	private Combo   c;

//-------------------------------------------------------------------
//
//-------------------------------------------------------------------
static public void main(String[] args) {
	new PR_1GLGA41().runMain(args);
}

//-------------------------------------------------------------------
//
//-------------------------------------------------------------------
private void runMain(String[] args) {

	display = new Display();
	
	shell = new Shell(display);
	shell.setText(getClass().getName());
	shell.setBounds(0,0,200,200);
	shell.setLayout(new GridLayout());
	
	c = new Combo(shell,SWT.DROP_DOWN | SWT.READ_ONLY);
	c.add("Item 1");
	c.add("Item 2");
	c.add("Item 3");
		
	shell.open();

	c.select(2);
	c.remove(0);
	System.out.println(c.getSelectionIndex()); // should be 1

	while (!shell.isDisposed()) {
		if (!display.readAndDispatch()) {
			display.sleep();
		}
	}
}


}

---- cut here ----------

NOTES:

=======================================
Comment 1 DJ Houghton CLA 2001-10-29 16:45:10 EST
PRODUCT VERSION:
	SWT 2.003 Photon

Comment 2 David Whiteman CLA 2002-01-08 12:52:35 EST
What's the status on this?
Comment 3 Silenio Quarti CLA 2002-05-15 14:24:09 EDT
Not sure why this was not fixed yet. Anyway, fixed >20020514.
Comment 4 David Whiteman CLA 2002-05-15 14:38:16 EDT
Thanks Silenio!