Skip to main content



      Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Hide/Show MenuItems in a Menu
Hide/Show MenuItems in a Menu [message #530265] Thu, 29 April 2010 03:16 Go to next message
Eclipse UserFriend
Is there a way to hide/show MenuItems inside a Menu?
Neither Menu provides something like menu.setVisible (int index_of_menu_item) nor MenuItem provides anything like menuitem.setVisible (boolean)

Thus, for menus whose contents change depending on the context, the code for creating menu is repeated over and over again (during each pop-up of the menu) which involves adding listeners for menu selection too.
This is quite inefficient I guess.

Simple hide/show mechanism will enable create-once-use-forever approach which will be very efficient.
Re: Hide/Show MenuItems in a Menu [message #530487 is a reply to message #530265] Thu, 29 April 2010 14:46 Go to previous message
Eclipse UserFriend
you're correct, removing menu items means disposing them. Adding one
back in the correct place involves creating the MenuItem with the
correct index.

In the eclipse Platform we use MenuManager and ContributionItems that
manage the logic of when to dispose and when to recreate MenuItems.
They come from org.eclipse.jface.

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/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm
Previous Topic:org.eclipse.swt.widgets.Text and Scroll bar
Next Topic:Wrong cell color return in Linux
Goto Forum:
  


Current Time: Wed Jul 23 07:48:26 EDT 2025

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

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

Back to the top