Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » right mouse click, mouse position
right mouse click, mouse position [message #211385] Fri, 10 March 2006 10:17 Go to next message
Jens Bartelheimer is currently offline Jens BartelheimerFriend
Messages: 44
Registered: July 2009
Member
Hi,

I am looking for a way to handle right clicks on an editpart. Important
is that I need the mouse position for the corresponding action. I have
found this post
http://dev.eclipse.org/newslists/news.eclipse.tools.gef/msg0 1158.html
but maybe it is out-of-date (three years old).

Is there another, simpler way today?

Regards,
Jens
Re: right mouse click, mouse position [message #211407 is a reply to message #211385] Fri, 10 March 2006 11:40 Go to previous messageGo to next message
Andreas Schosser is currently offline Andreas SchosserFriend
Messages: 30
Registered: July 2009
Member
One possible solution is adding a MouseListener to the corresponding
figure.
Following implementation might work:

import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.MouseEvent;
import org.eclipse.draw2d.MouseListener;


public class RightClickableEditPart extends AbstractGraphicalEditPart
implements MouseListener
{
protected IFigure createFigure()
{
IFigure figure = FigureFactory.createRightClickableFigure();
figure.addMouseListener(new RightClickMouseListener());
return figure;
}

private class RightClickMouseListener implements MouseListener
{
public void mousePressed(MouseEvent me)
{
// '2' for mouse button 2
if(me.button==2)
{
// right-clicked!
}
}

public void mouseReleased(MouseEvent me) { }

public void mouseDoubleClicked(MouseEvent me) { }
}
}

Kind regards,

--
Andreas Schosser
Mind8 GmbH


> Hi,
>
> I am looking for a way to handle right clicks on an editpart. Important
> is that I need the mouse position for the corresponding action. I have
> found this post
> http://dev.eclipse.org/newslists/news.eclipse.tools.gef/msg0 1158.html
> but maybe it is out-of-date (three years old).
>
> Is there another, simpler way today?
>
> Regards,
> Jens
Re: right mouse click, mouse position [message #211520 is a reply to message #211407] Mon, 13 March 2006 20:33 Go to previous message
Jens Bartelheimer is currently offline Jens BartelheimerFriend
Messages: 44
Registered: July 2009
Member
Hi Andreas,

thanks for your help. It works, but the behavior is strange. After the
first mouse click the mousePressed method arise, but after a second
click the contextmenu appears. The next click ends in the mousePressed
method again ?!?

Further I would like to show a modified context menu, depending on the
mouse position. Do you have an idea?

Regards,
Jens

Andreas Schosser wrote:
> One possible solution is adding a MouseListener to the corresponding
> figure.
> Following implementation might work:
>
> import org.eclipse.draw2d.IFigure;
> import org.eclipse.draw2d.MouseEvent;
> import org.eclipse.draw2d.MouseListener;
>
>
> public class RightClickableEditPart extends
> AbstractGraphicalEditPart implements MouseListener
> {
> protected IFigure createFigure()
> {
> IFigure figure = FigureFactory.createRightClickableFigure();
> figure.addMouseListener(new RightClickMouseListener());
> return figure;
> }
>
> private class RightClickMouseListener implements MouseListener
> {
> public void mousePressed(MouseEvent me)
> {
> // '2' for mouse button 2
> if(me.button==2)
> {
> // right-clicked!
> }
> }
>
> public void mouseReleased(MouseEvent me) { }
>
> public void mouseDoubleClicked(MouseEvent me) { }
> }
> }
>
> Kind regards,
>
> --Andreas Schosser
> Mind8 GmbH
>
>
>> Hi,
>>
>> I am looking for a way to handle right clicks on an editpart.
>> Important is that I need the mouse position for the corresponding
>> action. I have found this post
>> http://dev.eclipse.org/newslists/news.eclipse.tools.gef/msg0 1158.html
>> but maybe it is out-of-date (three years old).
>>
>> Is there another, simpler way today?
>>
>> Regards,
>> Jens
Previous Topic:RotatedRectangeFigure And Relevant Edit Policies Contribution
Next Topic:Access the Palette view by keyboard
Goto Forum:
  


Current Time: Fri Apr 19 21:54:08 GMT 2024

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

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

Back to the top