dropdown menu in main toolbar ... menu items can't be checked [message #329805] |
Sat, 05 July 2008 09:55  |
Eclipse User |
|
|
|
Hello.
I have two problems with my drop down action in the main toolbar.
I add the action via ApplicationActionBarAdvisor.fillCoolBar() method (see
little code snippet below please).
The problem is, that the menu item is not checkable (even the style
SWT.CHECKED is set).
Another little problem ... the little drop down arrow on the right side of
the button is constantly hovered as if the mouse cursor where on top of it
(even if the mouse cursor is somewhere else on the screen). why that?
My snippet:
@Override
protected void fillCoolBar(ICoolBarManager coolBar) {
//uiManager.registerMainCoolBarManager(coolBar);
Action action = new Action("test action", Action.AS_DROP_DOWN_MENU) {
@Override
public void run() {
System.out.println("testing");
}
};
action.setImageDescriptor(PlatformUI.getWorkbench().getShare dImages().getImageDescriptor(ISharedImages.IMG_TOOL_FORWARD) );
action.setMenuCreator(new IMenuCreator() {
private Menu listMenu;
@Override
public void dispose() {
if (listMenu != null)
listMenu.dispose();
}
@Override
public Menu getMenu(Control parent) {
if (listMenu != null)
listMenu.dispose();
listMenu = new Menu(parent);
MenuItem m1 = new MenuItem(listMenu, SWT.CHECK);
m1.setText("Can this be checked?");
return listMenu;
}
@Override
public Menu getMenu(Menu parent) {
return null;
}
});
ToolBarManager toolBarManager = new ToolBarManager();
toolBarManager.add(action);
coolBar.add(toolBarManager);
}
Best regards,
Kai
|
|
|
|
|
Re: dropdown menu in main toolbar ... menu items can't be checked [message #510865 is a reply to message #329805] |
Thu, 28 January 2010 16:16  |
Eclipse User |
|
|
|
Hello Kai,
I know this reply is a bit late, but I found the solution to your second problem, where the little down arrow in your AS_DROP_DOWN_MENU action constantly shows up as hovered/highlighted/hot even when the mouse isn't over it.
In your ApplicationActionBarAdvisor.fillCoolBar() method, you need to create your ToolBarManager with the SWT.FLAT style, like this:
ToolBarManager toolbarmanager = new ToolBarManager( SWT.FLAT );
I had this exact same problem, spent a whole day debugging it, and finally noticed that the RCP Mail template tutorial ( http://www.eclipse.org/articles/Article-RCP-3/tutorial3.html) used SWT.FLAT, but I didn't. Adding this one flag fixed the problem for me.
Enjoy,
-w
|
|
|
Powered by
FUDForum. Page generated in 0.07427 seconds