Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Adding context menu for Draw2d figures
Adding context menu for Draw2d figures [message #234119] Fri, 11 May 2007 18:31 Go to next message
Raheel Ashraf is currently offline Raheel AshrafFriend
Messages: 2502
Registered: July 2009
Senior Member
How do we add context menu to draw2d figures. I do realize that this
question has been asked before on the newsgroup and the answer given was:

"Popup menus can be invoked with the keyboard too (Shift+F10). Therefore
you
must have a notion of what is selected, and base your popup menu on
selection, not mouse location. There is no notion of selection in draw2d,
only in GEF."

http://dev.eclipse.org/newslists/news.eclipse.tools.gef/msg0 4320.html

Can anyone provide more details on how to do this. So if I have a
FigureCanvas and I add bunch for figures to it, what should I do. I am
thinking of somehow using hte findFigure methods in FigureCanvas to find
out which figure was selected. So I only need to find the coordinates
where the right mouse click occured? Is there a better way to do this?
Re: Adding context menu for Draw2d figures [message #234129 is a reply to message #234119] Fri, 11 May 2007 19:35 Go to previous messageGo to next message
Alex Boyko is currently offline Alex BoykoFriend
Messages: 200
Registered: July 2009
Senior Member
Hi,

Just ask your viewer for selected editparts, i.e. use
EditPartViewer#getSelectedEditParts().
Hope this helps.

Cheers,
Alex
Re: Adding context menu for Draw2d figures [message #234137 is a reply to message #234129] Fri, 11 May 2007 19:59 Go to previous messageGo to next message
Raheel Ashraf is currently offline Raheel AshrafFriend
Messages: 2502
Registered: July 2009
Senior Member
the problem is that i am not using GEf. I am only using the draw2d apis
which means that I am using SWT and stuff and only using FigureCanvas and
other figures that are added to teh FigureCanvas
Re: Adding context menu for Draw2d figures [message #234187 is a reply to message #234119] Mon, 14 May 2007 07:51 Go to previous message
Manuel Selva is currently offline Manuel SelvaFriend
Messages: 189
Registered: July 2009
Location: Grenoble, France
Senior Member
Hi,

You have the good idea. The only way to add the context menu is to add
your own inside your own listener. 2 solutions :

- the first you mentioned is to add a mouse listener on the canvas, and
find wich figure was selected.

- the second is to add a mouse listener to the figures that need context
menu (may be use a singleton listener to avoid lot of listener creation)

Hope this can help

Manuel Selva


Previous Topic:GEF tutorials and Books
Next Topic:Making shapes invisible & layer question
Goto Forum:
  


Current Time: Tue Mar 19 09:58:12 GMT 2024

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

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

Back to the top