How do I create an eclipse toolbar item with SWT.RADIO style and drop down?
In eclipse SWT land, it comes in handy when you can add multiple styles to
controls. Toolbars can have multiple styles added. Can tool items enjoy
the same privilege?
Basically, I would like to have a toolbar item to behave like a radio
button with a drop down. I want users to be able to change an item's
default action from a list of items in its drop down.
Can anyone kindly point me in the right direction?
...
ToolBar toolBar = new ToolBar(composite, SWT.FLAT | SWT.RIGHT |
SWT.HORIZONTAL);
ToolItem item1 = new ToolItem(toolBar, SWT.RADIO);
item1.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
// do something
}
});
item1.setImage(image1);
ToolItem item2 = new ToolItem(toolBar, SWT.RADIO | STW.DROP_DOWN);
//only allowed in my dreams
item2.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
// do something else
}
// allow user to choose a default action
});
item2.setImage(image2);
No comments:
Post a Comment