Community
Participate
Working Groups
- run the snippet below - on gtk and motif it behaves correctly and prints "true, false" - but on win32 and carbon is prints "true,"true" public static void main(String[] args) { final Display display = new Display(); Shell shell = new Shell(display); shell.setBounds(10,10,200,200); Tree tree = new Tree(shell, SWT.NONE); tree.setBounds(10,10,100,100); final TreeItem root = new TreeItem(tree, SWT.NONE); root.setText("General"); final TreeItem child = new TreeItem(root, SWT.NONE); child.setText("Error"); shell.open(); root.setExpanded(true); System.out.println(root.getExpanded()); child.dispose(); System.out.println(root.getExpanded()); // <---- while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
I agree we have inconsistency in here. My question is: This code: TreeItem root = new TreeItem(tree, SWT.NONE); root.setText("General"); root.setExpanded(true); TreeItem child = new TreeItem(root, SWT.NONE); child.setText("Error"); And this code here: TreeItem root = new TreeItem(tree, SWT.NONE); root.setText("General"); TreeItem child = new TreeItem(root, SWT.NONE); child.setText("Error"); root.setExpanded(true); When the shell opens and tree is visible, is root expanded ? Note that not allowing a childless item to be expand should cause the first snippet to be collapsed. see also Bug 40797
Steve, some platforms automatically change the expand state of a treeitem to false when the last child item is disposed. Other don't. Is that something we should make consistent across platforms ? Or just close this as platform behaviour ? (need to check if calling setExpand(true) works when an item has no children).
We need to make this consistent but not for 3.5.
*** This bug has been marked as a duplicate of bug 40797 ***