I created a toolbar with text field and two toolItem
The problem that the Text is exist in the right scrren and not in the left screen.
How I can put the text in the right screen ?
It should look :
Text item1 item2
ToolBar treeToolBar = new ToolBar(treeComposite, SWT.RIGHT_TO_LEFT);
Text text = new Text(treeToolBar, SWT.NONE);
text.setLayoutData(new GridData(SWT.FILL, SWT.LEFT, false, false));
text.setText("Text");
text.pack();
item1 = new ToolItem(treeToolBar, SWT.PUSH | SWT.RIGHT);
item2 = new ToolItem(treeToolBar, SWT.PUSH | SWT.RIGHT);
treeToolBar.pack();
After you create the text, you also have to create a tab item for it. Remove the text.pack()
call and insert this:
ToolItem textItem = new ToolItem(treeToolBar, SWT.SEPARATOR);
textItem.setControl(text);
textItem.setWidth(text.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
This is how ControlContribution
does in method fill(ToolBar parent, int index)
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.