Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » context menu for draw2d figure(how to add context menu on right click and keep other action on left click)
context menu for draw2d figure [message #495228] Wed, 04 November 2009 09:38 Go to next message
Stella Levin is currently offline Stella Levin
Messages: 88
Registered: July 2009
Member
Hi, I have a FigureCnavas thatcontains many draw2d Figures. I use MouseListener to perform action on click. Now I would like to keep the same action on left click and open context menu per figure on right click. How may I do this.? Any examples will be appreciated. Thanks, Stella
Re: context menu for draw2d figure [message #496889 is a reply to message #495228] Wed, 11 November 2009 16:27 Go to previous message
Stella Levin is currently offline Stella Levin
Messages: 88
Registered: July 2009
Member
Here is a solution how to create context menu:
FigureCanvas fc; // contains figures.
Menu menu = new Menu  (fc.getShell(), SWT.POP_UP);

// for leaf menu item
MenuItem itemA = new MenuItem(menu, SWT.PUSH);
itemA.setText("ItemA");
itemA.addListener(SWT.Selection, new Listener() {
     // swt.widget.Listener implementation
});

// for hierarchical menu item
MenuItem itemB = new MenuItem(menu, SWT.CASCADE);
itemB.setText("ItemB");
Menu subMenuB = new Menu(fc.getShell(), SWT.DROP_DOWN);
itemB.setMenu(subMenuB);
itemB.addListener(SWT.Show, new Listener() {
   MenuItem item = new MenuItem(subMenuB, SWT.PUSH);
...
});

Previous Topic:Vertical and Horizontal Arrangements in a Layout
Next Topic:compartment and layout manager
Goto Forum:
  


Current Time: Thu Oct 23 20:37:19 GMT 2014

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

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