Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Add a pull-down menu to an existing view's toolbar
Add a pull-down menu to an existing view's toolbar [message #294667] Tue, 15 November 2005 19:13 Go to next message
Eclipse UserFriend
Originally posted by: michael.xia.windriver.com

Hello,

With the available article, I am able to add menu items and toolbar icons
to an existing view, and I can create pullover submenus. However, I am
not sure how to make my new toolbar icon a pull-down menu. I can do that
for the main toolbar of the Workbench window using actionSets since it has
a "pulldown" property that I can set to true. For contributing to
individual view, the action in org.eclipse.ui.viewActions does not have
the same property. Any suggestion will be appreciated. Thanks!

Michael
Re: Add a pull-down menu to an existing view's toolbar [message #294671 is a reply to message #294667] Tue, 15 November 2005 21:10 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: douglas.pollock.magma.ca

Michael Xia wrote:
> With the available article, I am able to add menu items and toolbar icons
> to an existing view, and I can create pullover submenus. However, I am
> not sure how to make my new toolbar icon a pull-down menu. I can do that
> for the main toolbar of the Workbench window using actionSets since it has
> a "pulldown" property that I can set to true. For contributing to
> individual view, the action in org.eclipse.ui.viewActions does not have
> the same property. Any suggestion will be appreciated. Thanks!

Officially, you can't do it. In 3.2 M4 or 3.2 M5 you should be able to
using the "org.eclipse.ui.menus" extension point.

However, you might be able to get away with it by adding the following
attribute to your action (ignore any warnings or errors that are
displayed).

style="pulldown"

I'd love to hear whether that works for you.



cheers,
d.
Re: Add a pull-down menu to an existing view's toolbar [message #294672 is a reply to message #294671] Tue, 15 November 2005 21:41 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: michael.xia.windriver.com

Thanks Douglas! A drop-down arrow did appear with your suggestion! The
only thing I'm not sure now is if I should still implement
IViewActionDelegate since there isn't a local toolbar equivalent of
IWorkbenchWindowPulldownDelegate. Do I need to add mouse listener then to
draw the drop-down menus when the arrow is clicked?

Michael
Re: Add a pull-down menu to an existing view's toolbar [message #294717 is a reply to message #294672] Wed, 16 November 2005 15:18 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: douglas.pollock.magma.ca

Michael Xia wrote:
> Thanks Douglas! A drop-down arrow did appear with your suggestion! The
> only thing I'm not sure now is if I should still implement
> IViewActionDelegate since there isn't a local toolbar equivalent of
> IWorkbenchWindowPulldownDelegate. Do I need to add mouse listener then to
> draw the drop-down menus when the arrow is clicked?

Again, this is just a hack: no promises this will work in any future version
of Eclipse. Also, this forces your plug-in to be loaded eagerly, which can
cause performance problems. But, you can change your selectionChanged to
do the following:

public void selectionChanged(IAction action, ISelection selection) {
// Do whatever else you need to do.

// Hook up a menu creator
if (!menuCreatorSet) {
action.setMenuCreator(new IMenuCreator() { // for view menu
public Menu getMenu(Menu parent) {
Menu menu = new Menu(parent);
MenuItem menuItem = new MenuItem(menu, SWT.PUSH);
menuItem.setText("Monkey");
return menu;
}

public Menu getMenu(Control parent) { // for tool bar
Menu menu = new Menu(parent);
MenuItem menuItem = new MenuItem(menu, SWT.PUSH);
menuItem.setText("Monkey");
return menu;
}

public void dispose() {
// Do nothing
}
});
menuCreatorSet = true;
}
}



cheers,
d.
Re: Add a pull-down menu to an existing view's toolbar [message #294733 is a reply to message #294717] Wed, 16 November 2005 21:39 Go to previous message
Eclipse UserFriend
Originally posted by: michael.xia.windriver.com

Hi Douglas,

Thanks again for the help! It works.

Regards,
Michael
Previous Topic:All you Testers out there
Next Topic:question regarding the workspace and versioning.
Goto Forum:
  


Current Time: Sat May 10 10:29:35 EDT 2025

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

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

Back to the top