Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » How to get the EditPart at the mouse location?
How to get the EditPart at the mouse location? [message #192909] Tue, 23 August 2005 18:33 Go to next message
Felix L J Mayer is currently offline Felix L J MayerFriend
Messages: 202
Registered: July 2009
Senior Member
In order to correctly display my context menus, I need to know over which
EditPart the mouse currently is (I cannot use the selected EditPart).
Currently I have extended the org.eclipse.gef.tools.SelectionTool in order
to make one protected method public; this gives me access to the mouse
location since all relevant methods are not public. Then I set and load the
default tool on the DefaultEditDomain of my GraphicalEditor to my own
SelectionTool, so that I can get the EditPart at the current mouse from the
viewer.

This approach seems work, but I am wondering of there is a better way to do
this?
Re: How to get the EditPart at the mouse location? [message #192998 is a reply to message #192909] Wed, 24 August 2005 03:39 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: bashar.infromatik.uni-bonn.de

You may do it with EditPartViewer#findObjectAt(Point location).
But I think it's better to use SelectionAction#getSelectedObjects() instead.


"Felix L J Mayer" <felix.mayer@objectaid.com> wrote in message
news:defpuf$vts$1@news.eclipse.org...
> In order to correctly display my context menus, I need to know over which
> EditPart the mouse currently is (I cannot use the selected EditPart).
> Currently I have extended the org.eclipse.gef.tools.SelectionTool in order
> to make one protected method public; this gives me access to the mouse
> location since all relevant methods are not public. Then I set and load
> the default tool on the DefaultEditDomain of my GraphicalEditor to my own
> SelectionTool, so that I can get the EditPart at the current mouse from
> the viewer.
>
> This approach seems work, but I am wondering of there is a better way to
> do this?
>
Re: How to get the EditPart at the mouse location? [message #193125 is a reply to message #192998] Wed, 24 August 2005 15:26 Go to previous messageGo to next message
Felix L J Mayer is currently offline Felix L J MayerFriend
Messages: 202
Registered: July 2009
Senior Member
I am currently using EditPartViewer.findObjectAt(Point location) as
described below.
SelectionAction.getSelectedObjects() does not work if the object is not
selected, which frequently is the case when you just move the mouse around
and then right-click on something.

So currently I have the impression that something may have been overlooked
in GEF.

"Abul Bashar" <bashar@infromatik.uni-bonn.de> wrote in message
news:degq5o$4ed$1@news.eclipse.org...
> You may do it with EditPartViewer#findObjectAt(Point location).
> But I think it's better to use SelectionAction#getSelectedObjects()
> instead.
>
>
> "Felix L J Mayer" <felix.mayer@objectaid.com> wrote in message
> news:defpuf$vts$1@news.eclipse.org...
>> In order to correctly display my context menus, I need to know over which
>> EditPart the mouse currently is (I cannot use the selected EditPart).
>> Currently I have extended the org.eclipse.gef.tools.SelectionTool in
>> order to make one protected method public; this gives me access to the
>> mouse location since all relevant methods are not public. Then I set and
>> load the default tool on the DefaultEditDomain of my GraphicalEditor to
>> my own SelectionTool, so that I can get the EditPart at the current mouse
>> from the viewer.
>>
>> This approach seems work, but I am wondering of there is a better way to
>> do this?
>>
>
>
Re: How to get the EditPart at the mouse location? [message #193188 is a reply to message #192909] Wed, 24 August 2005 17:00 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

> In order to correctly display my context menus, I need to know over which
> EditPart the mouse currently is (I cannot use the selected EditPart).

context menus should be based *only* on selection. You can display a context
menu even if the mouse is outside of the control by pressing SHIFT+F10.

What is your motivation for differing from the platform behavior?
Re: How to get the EditPart at the mouse location? [message #193201 is a reply to message #193188] Wed, 24 August 2005 17:18 Go to previous messageGo to next message
Felix L J Mayer is currently offline Felix L J MayerFriend
Messages: 202
Registered: July 2009
Senior Member
"Randy Hudson" <none@us.ibm.com> wrote in message
news:dei92i$466$1@news.eclipse.org...
>> In order to correctly display my context menus, I need to know over which
>> EditPart the mouse currently is (I cannot use the selected EditPart).
>
> context menus should be based *only* on selection. You can display a
> context menu even if the mouse is outside of the control by pressing
> SHIFT+F10.
>
> What is your motivation for differing from the platform behavior?
>
This is the situation: suppose you move the mouse around the diagram without
selecting anything. Then, over a particular node, you right-click the mouse
to see the context menu related to that node. My problem is that the
right-click does not select the node at the mouse position, so I cannot use
the selected objects.

Actually I just tried it out and a right-click does select the node at the
mouse position. Was this changed since release 2.0 or 2.1? I guess then I
can use the selected objects.
Re: How to get the EditPart at the mouse location? [message #193209 is a reply to message #193201] Wed, 24 August 2005 17:24 Go to previous messageGo to next message
Felix L J Mayer is currently offline Felix L J MayerFriend
Messages: 202
Registered: July 2009
Senior Member
"Felix L J Mayer" <felix.mayer@objectaid.com> wrote in message
news:dei9ta$5av$1@news.eclipse.org...
> "Randy Hudson" <none@us.ibm.com> wrote in message
> news:dei92i$466$1@news.eclipse.org...
>>> In order to correctly display my context menus, I need to know over
>>> which EditPart the mouse currently is (I cannot use the selected
>>> EditPart).
>>
>> context menus should be based *only* on selection. You can display a
>> context menu even if the mouse is outside of the control by pressing
>> SHIFT+F10.
>>
>> What is your motivation for differing from the platform behavior?
>>
> This is the situation: suppose you move the mouse around the diagram
> without selecting anything. Then, over a particular node, you right-click
> the mouse to see the context menu related to that node. My problem is that
> the right-click does not select the node at the mouse position, so I
> cannot use the selected objects.
>
> Actually I just tried it out and a right-click does select the node at the
> mouse position. Was this changed since release 2.0 or 2.1? I guess then I
> can use the selected objects.
Hm, when I press Shift+F10 the node at the mouse position is not selected;
at least it doesn't show the proper visual feedback. But when I right-click
the node, I do get the selection rectangle.
Re: How to get the EditPart at the mouse location? [message #193326 is a reply to message #193209] Thu, 25 August 2005 08:22 Go to previous message
Martijn van Steenbergen is currently offline Martijn van SteenbergenFriend
Messages: 16
Registered: July 2009
Junior Member
Felix L J Mayer wrote:
> Hm, when I press Shift+F10 the node at the mouse position is not selected;
> at least it doesn't show the proper visual feedback. But when I right-click
> the node, I do get the selection rectangle.

If I understand Randy correctly, pressing Shift+F10 shows the context
menu for the current selection. It does not (directly) change the selection.

Martijn.
Previous Topic:position and reposition Figure’s children
Next Topic:Grouping components for a drag
Goto Forum:
  


Current Time: Thu Apr 25 19:21:41 GMT 2024

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

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

Back to the top