Community
Participate
Working Groups
Run the following code. On Linux, you can hit Ctrl-F to bring up a typeahead dialog to search the list. If you type an invalid name, the selection can go blank, at which point the list receives a selection event with the selected index being -1. This case cannot occur on Win32: once the list has a selection, it cannot lose it. public static void main(String [] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); final List list = new List(shell, SWT.SINGLE); for(int i = 0; i < 10; i++) { list.add("This is item " + i); } list.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) {} public void widgetSelected(SelectionEvent e) { System.out.println("Selection event"); System.out.println("The selected item is: " + list.getSelectionIndex()); } }); shell.setSize(200,200); shell.open(); while(!shell.isDisposed()) { if(!display.readAndDispatch()) display.sleep(); } display.dispose(); }
Moving report to triage, see http://www.eclipse.org/swt/triage.php for more info about swt bug handling.
It is the native behavior of GTK that the none of the items might be selected during search operation. During single selection, GTK only enforces that the user can not deselect the existing selection. I couldn't find any way (even the search position callbacks are not helpful) in GTK to persist the single selection after the search. So, I feel this can be closed as WONTFIX.
The selection disappearing on Ctrl+F with GTK seems to me like a bug, so I've reported a bug at GTK [1] This looks ok from the SWT side, as SWT+GTK correctly sets selectionmode GTK_SELECTION_MODE_BROWSE to the native treeview selection, which according to the gtk docs should guarantee that one and only one ("exactly one") item is selected [2]. Based on the above investigation, this bug could be closed with WONTFIX or NOTABUG or something showing that there's nothing to be fixed on the eclipse side. [1] https://bugzilla.gnome.org/show_bug.cgi?id=748701 [2] https://developer.gnome.org/gtk3/stable/gtk3-Standard-Enumerations.html#GtkSelectionMode
closed as the bug in https://bugzilla.gnome.org/show_bug.cgi?id=748701 is not reproducible and been closed