Community
Participate
Working Groups
Setting the Font of a TreeItem to Bold styl makes it require more horizontal width. This results in a horizontal scrollbar in case the available width is not enough. However, when resetting the TreeItem back to normal Font, the Scrollbar is still showing, even if not required. Steps to reproduce: - After start, resize the Sash to the left so that a horizontal Scrollbar is showing. - Now press the Button, the font of the TreeItem is changing to Bold. Notice that the horizontal Scrollbar is growing a bit (as expected). - Now press the button again, the font of the TreeItem changes back to normal, but the Scrollbar is now becoming smaller. Expected results: The scrollbar sizes back to its original size that it had after start. Snippet: public class Main { static boolean showsBold = false; public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); final Font boldFont = new Font(display, "Helvetica", 20, SWT.BOLD); final Font normalFont = new Font(display, "Helvetica", 20, SWT.NORMAL); SashForm form = new SashForm(shell, SWT.HORIZONTAL | SWT.SMOOTH); form.setLayout(new FillLayout()); final Composite child1 = new Composite(form, SWT.NONE); child1.setLayout(new GridLayout(1, false)); Composite child2 = new Composite(form, SWT.NONE); child2.setLayout(new FillLayout()); final Tree tree = new Tree(child1, SWT.BORDER); tree.setFont(normalFont); tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); final TreeItem item = new TreeItem(tree, SWT.NONE); item.setText("Hello World Hello World"); item.setFont(normalFont); Button b = new Button(child2, SWT.PUSH); b.setText("push me"); b.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { if (!showsBold) item.setFont(boldFont); else item.setFont(normalFont); showsBold = !showsBold; } }); form.setWeights(new int[] { 50, 50 }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } } }
Typo: "- Now press the button again, the font of the TreeItem changes back to normal, but the Scrollbar is now becoming smaller." is meant to be "- Now press the button again, the font of the TreeItem changes back to normal, but the Scrollbar is _NOT_ becoming smaller."
I'm working on an in-place editor and I also see this problem. I noticed that the Navigator view also has an in-place editor and does not have this problem, but I haven't figured out what the difference is. Calls to pack() and layout(true) don't have any effect though.
Yes, the "in place" Editor of the Navigator is definitly something different to what is described in the Snippets section or the TreeEditor's JavaDoc. I already posted to the newsgroup asking for how Eclipse is doing it but did not yet received an answer. The main differences I noticed is: 1.) The black-box (edit textfield) has a bigger width in Eclipse's Navigator 2.) The text of the TreeItem that is being edited is not moving to the left. In the Snippet I am seeing a slight movement (~1px) to the left as soon as the editing begins. Ben
This is Windows platform behavior. It looks like Windows never makes the scroll bar smaller. I changed your code to set a new smaller string ("a") and never set the font. The scroll bar stayed.
Please open another bug report describing what you are seeing in the in-place editor if you want to persue that matter. Thanks.