Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Popup menu from menu item, similar to IE Favorites popup(Popup menu from menu item, similar to IE Favorites popup)
Popup menu from menu item, similar to IE Favorites popup [message #517307] Fri, 26 February 2010 21:52 Go to next message
Bo Ens is currently offline Bo EnsFriend
Messages: 10
Registered: January 2010
Junior Member
Is there a way to create a popup menu that gets displayed when an operator right clicks a menu item from another menu?

Since menu items are not controls, don't think this can be done because I cannot figure out how to register mouse events.

This would be similar to the right-click menu on IE Favorites or Firefox Bookmarks.

Thanks
Re: Popup menu from menu item, similar to IE Favorites popup [message #517482 is a reply to message #517307] Sun, 28 February 2010 16:01 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

The short answer is no, the system menus don't support this. You would
need to create something that looks like a menu, but is really a
control, a composite or canvas (there might be an example out there
already, as SWT MenuItem has never been able to support another menu,
but I wasn't able to find it).

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


Re: Popup menu from menu item, similar to IE Favorites popup [message #517535 is a reply to message #517482] Mon, 01 March 2010 08:52 Go to previous message
Vijay RajFriend
Messages: 608
Registered: July 2009
Senior Member
I saw this type of behavior in bookmarks menu in mozilla and favorites menu in IE....

Yes i too agree, i think it would be a drop down menu kind of thing with a shell which looks like a menu...

For start you can try this..

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.Shell;


public class MenuInMenu {
	public static void main(String[] args) {
		Display display = new Display();
		final Shell shell = new Shell(display);
		shell.setSize(400,300);
		Menu m = new Menu(shell, SWT.BAR);
		MenuItem file = new MenuItem(m, SWT.CASCADE);
	    file.setText("File");
	    file.addSelectionListener(new SelectionListener() {
			
			@Override
			public void widgetSelected(SelectionEvent e) {
				Shell s = new Shell(shell,SWT.None);
				Rectangle bounds = shell.getBounds();
				s.setBounds(new Rectangle(bounds.x, bounds.y+50, 100, 150));
				s.open();
				
			}
			
			@Override
			public void widgetDefaultSelected(SelectionEvent e) {
				// TODO Auto-generated method stub
				
			}
		});
		shell.setMenuBar(m);
		shell.open ();
		 while (!shell.isDisposed()) {
			    if (!display.readAndDispatch ()) display.sleep ();
			  }
			  display.dispose ();	
	}
	
}


Note you have to position the opened shell properly and should handle closing of the shell also...

add any control to the shell hence popups to them...


---------------------
why, mr. Anderson, why, why do you persist?
Because I Choose To.
Regards,
Vijay

[Updated on: Mon, 01 March 2010 09:27]

Report message to a moderator

Previous Topic:custom drawing table items in GTK 2.18
Next Topic:arrayindexoutofbounds when adding a new element to a tableviewer
Goto Forum:
  


Current Time: Sat Dec 07 18:02:30 GMT 2024

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

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

Back to the top