Left Upper Context Menu Location [message #524541] |
Thu, 01 April 2010 06:53  |
Eclipse User |
|
|
|
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 #524776 is a reply to message #524764] |
Fri, 02 April 2010 04:14   |
Eclipse User |
|
|
|
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 04:14   |
Eclipse User |
|
|
|
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 #525441 is a reply to message #525390] |
Tue, 06 April 2010 06:24  |
Eclipse User |
|
|
|
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.
|
|
|
Powered by
FUDForum. Page generated in 0.14462 seconds