Bug 85586 - [consistency] Can deselect items in a single selection list
Summary: [consistency] Can deselect items in a single selection list
Status: CLOSED WORKSFORME
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.1   Edit
Hardware: PC Linux-GTK
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Bogdan Gheorghe CLA
URL:
Whiteboard:
Keywords: consistency
Depends on:
Blocks:
 
Reported: 2005-02-16 16:49 EST by Billy Biggs CLA
Modified: 2017-06-21 16:01 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Billy Biggs CLA 2005-02-16 16:49:18 EST
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();
}
Comment 1 Grant Gayed CLA 2009-09-25 16:42:24 EDT
Moving report to triage, see http://www.eclipse.org/swt/triage.php
for more info about swt bug handling.
Comment 2 Praveen CLA 2009-12-02 01:25:52 EST
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.
Comment 3 Robert Roth CLA 2015-04-30 08:31:39 EDT
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
Comment 4 Ian Pun CLA 2017-06-21 16:01:13 EDT
closed as the bug in https://bugzilla.gnome.org/show_bug.cgi?id=748701 is not reproducible and been closed