Community
Participate
Working Groups
20060807-2000 - select a .java file in the pkg explorer - enable the *.java filter > expected: the first element in the previous selection's parent chain is selected < actual: no (or hidden) selection. Using the arrow keys goes to the top of the package explorer, which really hurts keyboard navigation. Note: sometimes, the selection seems to be maintained, but hidden. Then, using arrow keys will select the next/previous visible element after/before the initial selection.
See also bug 380043. This is partly an OS-dependent problem. On Windows, the selection in a tree is also empty after the selection disappears from the tree, but an item close to the original selection gets the focus ring. The user can easily select the next/previous/parent item with arrow keys or Space. On Mac and GTK, the concept of an unselected focus item seems to be missing. We could try to work around this platform blooper, but I don't think we should touch this on Windows.
*** Bug 380043 has been marked as a duplicate of this bug. ***
These are platform problems that could be fixed in SWT. public static void main(String [] args) { Display display = new Display(); Shell shell = new Shell (display); shell.setText("Multiple lines in a TreeItem"); shell.setLayout (new FillLayout()); final Tree tree = new Tree(shell, SWT.MULTI); int itemCount = 5; for (int i=0; i<itemCount; i++) { TreeItem item1 = new TreeItem(tree, SWT.NONE); item1.setText("item "+i); for (int j=0; j<itemCount; j++) { TreeItem item2 = new TreeItem(item1, SWT.NONE); item2.setText("item ["+i+" "+j+"]"); for (int k=0; k<itemCount; k++) { TreeItem item3 = new TreeItem(item2, SWT.NONE); item3.setText("item ["+i+" "+j+" "+k+"]"); } } } tree.getItem(1).setExpanded(true); tree.getItem(1).getItem(1).setExpanded(true); tree.setSelection(tree.getItem(1).getItem(1).getItem(1)); tree.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.keyCode == SWT.DEL) { TreeItem[] selection = tree.getSelection(); for (TreeItem item : selection) { item.dispose(); } } } }); shell.setSize(600, 400); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); } What happens when an element is deleted? * Windows 7: Selection is cleared, focus goes to next item on same level, or to parent item if the last item is deleted. => Good. Nothing to do. * Linux GTK2: Selection is cleared, focus disappears, up/down arrow keys put focus on first item in tree. => Bad: context is lost. => Nothing to do, since GTK2 is going to be phased out. * Linux GTK3: Selection goes to next item. (In views, selection is cleared and focus goes to next item; not sure why that is). => OK, but the strategy is not too smart. * Mac: Selection is cleared. Platform doesn't support concept of focus item. up/down arrow keys select last/first item. => Bad. Platform defect. In the Finder, they try to be smarter and select the next item on delete. But they fail if the deleted item is an expanded folder that has children: In that case, they first select the next item and then delete the folder. Result: nothing selected.
*** Bug 473802 has been marked as a duplicate of this bug. ***