case SWT.Dispose: if (getShell() != popup.getParent()) { String[] items = list.getItems(); int selectionIndex = list.getSelectionIndex(); popup = null; list = null; createPopup(items, selectionIndex); } break;
void listEvent (Event event) {	switch (event.type) {		case SWT.FocusIn: {			if (hasFocus) return;			hasFocus = true;			if (getEditable ()) text.selectAll ();			Event e = new Event();			e.time = event.time;			notifyListeners(SWT.FocusIn, e);			break;		}		case SWT.FocusOut: {			event.display.asyncExec(new Runnable() {				public void run() {					if (CCombo.this.isDisposed()) return;					Control focusControl = getDisplay().getFocusControl();					if (focusControl == arrow || focusControl == list || focusControl == text) return;					hasFocus = false;					Event e = new Event();					notifyListeners(SWT.FocusOut, e);				}			});			break;		}		case SWT.MouseUp: {			if (event.button != 1) return;			dropDown (false);			break;		}		case SWT.Selection: {			int index = list.getSelectionIndex ();			if (index == -1) return;			text.setText (list.getItem (index));			text.selectAll ();			list.setSelection(index);			Event e = new Event();			e.time = event.time;			e.stateMask = event.stateMask;			e.doit = event.doit;			notifyListeners(SWT.Selection, e);			event.doit = e.doit;			break;		}		case SWT.Traverse: {			switch (event.detail) {				case SWT.TRAVERSE_RETURN:				case SWT.TRAVERSE_ESCAPE:				case SWT.TRAVERSE_ARROW_PREVIOUS:				case SWT.TRAVERSE_ARROW_NEXT:					event.doit = false;					break;			}			Event e = new Event();			e.time = event.time;			e.detail = event.detail;			e.doit = event.doit;			e.character = event.character;			e.keyCode = event.keyCode;			notifyListeners(SWT.Traverse, e);			event.doit = e.doit;			event.detail = e.detail;			break;		}		case SWT.KeyUp: {					Event e = new Event();			e.time = event.time;			e.character = event.character;			e.keyCode = event.keyCode;			e.stateMask = event.stateMask;			notifyListeners(SWT.KeyUp, e);			break;		}		case SWT.KeyDown: {			if (event.character == SWT.ESC) { 				// Escape key cancels popup list				dropDown (false);			}			if ((event.stateMask & SWT.ALT) != 0 && (event.keyCode == SWT.ARROW_UP || event.keyCode == SWT.ARROW_DOWN)) {				dropDown (false);			}			if (event.character == SWT.CR) {				// Enter causes default selection				dropDown (false);				Event e = new Event();				e.time = event.time;				e.stateMask = event.stateMask;				notifyListeners(SWT.DefaultSelection, e);			}			// At this point the widget may have been disposed.			// If so, do not continue.			if (isDisposed()) break;			Event e = new Event();			e.time = event.time;			e.character = event.character;			e.keyCode = event.keyCode;			e.stateMask = event.stateMask;			notifyListeners(SWT.KeyDown, e);			break;					}	}}