Get position within action [message #98742] |
Sat, 11 October 2003 17:28  |
Eclipse User |
|
|
|
Originally posted by: felix.mayer.comcast.net
I have an EditorPartAction that is used from within a context menu on my
diagram. To check if the action should be enabled, I would like to know if
the mouse was right-clicked on a node or somewhere else within the diagram.
When the action is executed, I would like to have the coordinates where the
right-click happened. Can anybody give me a hint as to how I could achieve
that? I looked around in the action classes and couldn't find anything.
Thanks, Felix
|
|
|
|
Re: Get position within action [message #99370 is a reply to message #98877] |
Mon, 13 October 2003 10:35   |
Eclipse User |
|
|
|
You can't rely on the mouse location when bringing up the context menu,
because the user could open the context menu with the keyboard
(Shift+F10) and the mouse could be somewhere off the editor. I would
suggest your action look at selection, not mouse location, to determine
enablement. If the selected edit parts are all nodes, the action is
enabled. Otherwise, the action is disabled. The logic editor does this
with LEDs and the increment/decrement actions (see
IncrementDecrementAction.canPerformAction()).
Felix Mayer wrote:
> Actually, I think what I really need to know is where the mouse was
> right-clicked.
>
> "Felix Mayer" <felix.mayer@comcast.net> wrote in message
> news:bm9smg$ilv$1@eclipse.org...
>
>>I have an EditorPartAction that is used from within a context menu on my
>>diagram. To check if the action should be enabled, I would like to know if
>>the mouse was right-clicked on a node or somewhere else within the
>
> diagram.
>
>>When the action is executed, I would like to have the coordinates where
>
> the
>
>>right-click happened. Can anybody give me a hint as to how I could achieve
>>that? I looked around in the action classes and couldn't find anything.
>>
>>Thanks, Felix
>>
>>
>
>
>
|
|
|
Re: Get position within action [message #99764 is a reply to message #99370] |
Tue, 14 October 2003 15:54  |
Eclipse User |
|
|
|
Originally posted by: felix.mayer.comcast.net
Since I had to whole weekend, I was able to figure something out:
Within the action, I am able to get the IWorkbenchPart, from that the
DefaultEditDomain, from that the SelectionTool and from that the
AbstractTool.Input, which gives me a mouse location. But I had to extend
SelectionTool in order to make AbstractTool.getCurrentInput() public and
then tell the DefaultEditDomain about it.
Is there a better way to do that?
The issue you mention is not a problem because I do IFigure.findFigureAt()
on the mouse location, which covers the special cases you mention: I only
proceed if a particular figure is at the mouse position.
"Eric Bordeau" <ebordeau@us.ibm.com> wrote in message
news:bmed6s$b6$1@eclipse.org...
> You can't rely on the mouse location when bringing up the context menu,
> because the user could open the context menu with the keyboard
> (Shift+F10) and the mouse could be somewhere off the editor. I would
> suggest your action look at selection, not mouse location, to determine
> enablement. If the selected edit parts are all nodes, the action is
> enabled. Otherwise, the action is disabled. The logic editor does this
> with LEDs and the increment/decrement actions (see
> IncrementDecrementAction.canPerformAction()).
>
> Felix Mayer wrote:
> > Actually, I think what I really need to know is where the mouse was
> > right-clicked.
> >
> > "Felix Mayer" <felix.mayer@comcast.net> wrote in message
> > news:bm9smg$ilv$1@eclipse.org...
> >
> >>I have an EditorPartAction that is used from within a context menu on my
> >>diagram. To check if the action should be enabled, I would like to know
if
> >>the mouse was right-clicked on a node or somewhere else within the
> >
> > diagram.
> >
> >>When the action is executed, I would like to have the coordinates where
> >
> > the
> >
> >>right-click happened. Can anybody give me a hint as to how I could
achieve
> >>that? I looked around in the action classes and couldn't find anything.
> >>
> >>Thanks, Felix
> >>
> >>
> >
> >
> >
>
|
|
|
Powered by
FUDForum. Page generated in 0.50008 seconds