Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Left Upper Context Menu Location(Left Upper Context Menu Location)
Left Upper Context Menu Location [message #524541] Thu, 01 April 2010 10:53 Go to next message
GEF is currently offline GEFFriend
Messages: 8
Registered: April 2010
Junior Member
Hello, my name is Federico. I am implementing a GUI .I need to get the left upper Context menu Location.

My problem is the following: When I press the right mouse button, the contextual menu is dispalyed, after that the user is able to create several kind of objects, when the user pick in a particular option a new object must appear in the position where the user has pressed the right button.

I hope you can undertand my problem and someone can help me.

Thank you in advance!
Federico.-
Re: Left Upper Context Menu Location [message #524588 is a reply to message #524541] Thu, 01 April 2010 09:32 Go to previous messageGo to next message
h1055071 is currently offline h1055071Friend
Messages: 335
Registered: July 2009
Senior Member
On 01/04/2010 11:53, fededobals@hotmail.com wrote:
> Hello, my name is Federico. I am implementing a GUI .I need to get the
> left upper Context menu Location.
>
> My problem is the following: When I press the right mouse button, the
> contextual menu is dispalyed, after that the user is able to create
> several kind of objects, when the user pick in a particular option a new
> object must appear in the position where the user has pressed the right
> button.
>
> I hope you can undertand my problem and someone can help me.
>
> Thank you in advance!
> Federico.-

Hi Frederico,

you're in luck. I implemented this only yesterday...

In my Graphical Editor I added a listener for context menu clicks:

final GraphicalViewer viewer = getGraphicalViewer();
viewer.getControl().addMenuDetectListener(new MenuDetectListener() {
public void menuDetected(MenuDetectEvent e) {
Point pt = viewer.getControl().toControl(e.x, e.y);
// Do something with pt...
}
});

You must then use the x,y points in pt for your creation command.

Phil
Re: Left Upper Context Menu Location [message #524764 is a reply to message #524588] Fri, 02 April 2010 11:38 Go to previous messageGo to next message
GEF is currently offline GEFFriend
Messages: 8
Registered: April 2010
Junior Member
Hello Phil,

Thank you for your help.

Please forgive me for my novice ignorance but when you say :

// Do something with pt...

What is supposed I must do there?

In addition, I have not clear how to acced to the point captured for the event from the CreateCommand class.

If you could help me It would be great!

Thank you!
Federico
Re: Left Upper Context Menu Location [message #524776 is a reply to message #524764] Fri, 02 April 2010 08:14 Go to previous messageGo to next message
h1055071 is currently offline h1055071Friend
Messages: 335
Registered: July 2009
Senior Member
On 02/04/2010 12:38, fededobals@hotmail.com wrote:
> Hello Phil,
> Thank you for your help.
>
> Please forgive me for my novice ignorance but when you say :
>
> // Do something with pt...
>
> What is supposed I must do there?
>
> In addition, I have not clear how to acced to the point captured for the
> event from the CreateCommand class.
> If you could help me It would be great!
>
> Thank you!
> Federico

Hello,

Point pt has x and y properties, pt.x and pt.y. You need to send these
x,y co-ordinates to your Menu Action which will create the Command.

Assuming you declare your Action in your GEF Editor you could set the
x,y position in your action. I use it in a "Paste" Action like this:

viewer.getControl().addMenuDetectListener(new
MenuDetectListener() {
public void menuDetected(MenuDetectEvent e) {
PasteAction action =
(PasteAction)getActionRegistry().getAction(ActionFactory.PAS TE.getId());
Point pt = viewer.getControl().toControl(e.x, e.y);
action.setMouseClickPosition(pt.x, pt.y);
}
});
Re: Left Upper Context Menu Location [message #524777 is a reply to message #524776] Fri, 02 April 2010 08:14 Go to previous messageGo to next message
h1055071 is currently offline h1055071Friend
Messages: 335
Registered: July 2009
Senior Member
On 02/04/2010 14:00, Phillipus wrote:
> On 02/04/2010 12:38, fededobals@hotmail.com wrote:
>> Hello Phil,
>> Thank you for your help.
>>
>> Please forgive me for my novice ignorance but when you say :
>>
>> // Do something with pt...
>>
>> What is supposed I must do there?
>>
>> In addition, I have not clear how to acced to the point captured for the
>> event from the CreateCommand class.
>> If you could help me It would be great!
>>
>> Thank you!
>> Federico
>
> Hello,
>
> Point pt has x and y properties, pt.x and pt.y. You need to send these
> x,y co-ordinates to your Menu Action which will create the Command.
>
> Assuming you declare your Action in your GEF Editor you could set the
> x,y position in your action. I use it in a "Paste" Action like this:
>
> viewer.getControl().addMenuDetectListener(new MenuDetectListener() {
> public void menuDetected(MenuDetectEvent e) {
> PasteAction action =
> (PasteAction)getActionRegistry().getAction(ActionFactory.PAS TE.getId());
> Point pt = viewer.getControl().toControl(e.x, e.y);
> action.setMouseClickPosition(pt.x, pt.y);
> }
> });
>
>
>

Another way to do it would be to let your Action have access to the
GraphicalViewer and let it be the MenuDetectListener
Re: Left Upper Context Menu Location [message #525390 is a reply to message #524776] Tue, 06 April 2010 13:11 Go to previous message
GEF is currently offline GEFFriend
Messages: 8
Registered: April 2010
Junior Member
Hi,

Thank you for your help and time used to explain all these concepts.

It was a great help, finally I understood and the problem was solved. Very Happy

Please, just a last question...Where can I get a good tutorial where explain all these tricky issues about GEF? or Where did you learn all what you explained to me?

Thank you,

Federico

Re: Left Upper Context Menu Location [message #525441 is a reply to message #525390] Tue, 06 April 2010 10:24 Go to previous message
h1055071 is currently offline h1055071Friend
Messages: 335
Registered: July 2009
Senior Member
On 06/04/2010 14:11, fededobals@hotmail.com wrote:
> Hi,
>
> Thank you for your help and time used to explain all these concepts.
> It was a great help, finally I understood and the problem was solved. :d
> Please, just a last question...Where can I get a good tutorial where
> explain all these tricky issues about GEF? or Where did you learn all
> what you explained to me?
>
> Thank you,
>
> Federico
>
>

Hi,

for me it is achieved through trial and error and looking through all
the GEF examples I can find. I have been thinking for some time about
there should be a Wiki for tips and tricks.
Previous Topic:Icon label parallel to connection
Next Topic:GEF documentation and examples is lacking - we need a GEF WIKI!
Goto Forum:
  


Current Time: Thu Apr 25 13:55:39 GMT 2024

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

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

Back to the top