I would like to create dynamic cascading menu items as follows:
When the user hovers over menu item A, it shows dynamic sub menu items b1, b2 and b3. On hovering over b1, it will show dynamic sub menu items c1 and c2 (similarly for b2 and b3). Is it possible to create a dynamic submenu under a dynamic submenu item? If so, is there an example?
Paul Webster Messages: 6831 Registered: July 2009 Location: Ottawa
Senior Member
On 04/05/2011 06:03 PM, venk wrote:
> I would like to create dynamic cascading menu items as follows:
> When the user hovers over menu item A, it shows dynamic sub menu items
> b1, b2 and b3. On hovering over b1, it will show dynamic sub menu items
> c1 and c2 (similarly for b2 and b3). Is it possible to create a dynamic
> submenu under a dynamic submenu item? If so, is there an example?
Keep in mind that multiple cascading menus are a poor UX design pattern.
That being said, where are you trying to create them? Main menu? view
menu? context menu?
Ok...This is what I wish to do.
I have added a menu under "Project". I am adding a new dynamic under the menu. Under dynamic I add a new class which extends CompoundContributionItem. This would look something like
I override getContributionItems() in my class which returns contribution items. Each of these items return other contribution items thus making it a dynamic cascading menu. I was wondering if there is a way to do it or if I could find a snippet somewhere.
Paul Webster Messages: 6831 Registered: July 2009 Location: Ottawa
Senior Member
On 04/11/2011 04:56 PM, venk wrote:
> CompoundContributionItem. This would look something like
> org.eclipse.ui.menus
> |
> |==== menu:project?after=additions (menuContribution)
> |
> |==== <menu> (menu)
> |
> |==== <dynamic> (dynamic)
> |
> |==== <CompoundContributionCommand> (class)
>
From your CompoundContributionItem you can create MenuManagers and fill
them in with further CommandContributionItems or more MenuManager
(creating a cascading menu structure).
I have one more question pertaining to this. If I want to change the style of menu item (from SWT_PUSH to SWT_CHECK), can I change it on the MenuManager? I am returning menu managers in getContributionItems. Is there any way to do it in my scenario?