[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform] Re: dropdown menu in main toolbar ... menu items can't be checked

Here again my code snippet, much more easier to read:
http://pastey.net/90654

Kai Schlamp wrote:

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().getSharedImages().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