|
|
|
Re: Left Upper Context Menu Location [message #524776 is a reply to message #524764] |
Fri, 02 April 2010 08:14 |
h1055071 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 |
h1055071 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
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03343 seconds