Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » dropdown menu in main toolbar ... menu items can't be checked
dropdown menu in main toolbar ... menu items can't be checked [message #329805] Sat, 05 July 2008 13:55 Go to next message
Kai Schlamp is currently offline Kai SchlampFriend
Messages: 344
Registered: July 2009
Senior Member
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 #329806 is a reply to message #329805] Sat, 05 July 2008 14:22 Go to previous messageGo to next message
Kai Schlamp is currently offline Kai SchlampFriend
Messages: 344
Registered: July 2009
Senior Member
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().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 #329932 is a reply to message #329805] Thu, 10 July 2008 19:16 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

If you dispose the listMenu every time, all of the item state is gone
.... wouldn't use need to save/manage the state somehow in your
IMenuCreator so it could be set correctly on any getMenu(*) call?

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm


Re: dropdown menu in main toolbar ... menu items can't be checked [message #510865 is a reply to message #329805] Thu, 28 January 2010 21:16 Go to previous message
Wade Walker is currently offline Wade WalkerFriend
Messages: 4
Registered: July 2009
Junior Member
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
Previous Topic:API for eclipse.ini
Next Topic:[Databinding] How to manipulate record order in a TableViewer
Goto Forum:
  


Current Time: Thu Apr 25 21:53:02 GMT 2024

Powered by FUDForum. Page generated in 0.03035 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top