Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » How to calculate the cursor Position in a Eclipse graphical editor ??
How to calculate the cursor Position in a Eclipse graphical editor ?? [message #646602] Wed, 29 December 2010 05:05 Go to next message
EclipseNoob  is currently offline EclipseNoob Friend
Messages: 10
Registered: December 2010
Junior Member
Hello Guys !!!

I have an editor which extends a GraphicalEditor .......... and my editor a few connectable figures.

I want to copy and paste a connectable figure on the editor ...... all the copying and pasting stuff works fine for me.

The issue is with the calculation of the paste location (in this case ... the cursor position after copying a connectable figure)

I do something like this ........

public Point getCursorPosition() {
Display display = Display.getDefault();
Point point = getGraphicalViewer().getControl().toControl(display.getCurso rLocation());
return point;
}


This works fine as long as the graphical editor has no scrolling !!!

Once i place the connectabe figures such that the editor has a scroll bar ..... and then do the copy ..... and paste ..... the paste does not happen at the location of my mouse pointer ...... but at positions little off my cursor !!!

Please help me out here .....

Thanx in advance Sad
Re: How to calculate the cursor Position in a Eclipse graphical editor ?? [message #646896 is a reply to message #646602] Sun, 02 January 2011 19:14 Go to previous messageGo to next message
Devi Vara Prasad Bandaru is currently offline Devi Vara Prasad BandaruFriend
Messages: 100
Registered: March 2010
Location: Hyderabad
Senior Member

	public Point getCursorPosition() {
		Display display = Display.getDefault();
		Point point = getGraphicalViewer().getControl().toControl(display.getCursorLocation());
		FigureCanvas figureCanvas = (FigureCanvas)getGraphicalViewer().getControl();
		org.eclipse.draw2d.geometry.Point location = figureCanvas.getViewport().getViewLocation();
		point = new Point(point.x + location.x, point.y + location.y);
		return point;
	}



Re: How to calculate the cursor Position in a Eclipse graphical editor ?? [message #646916 is a reply to message #646896] Mon, 03 January 2011 06:42 Go to previous messageGo to next message
EclipseNoob  is currently offline EclipseNoob Friend
Messages: 10
Registered: December 2010
Junior Member
Heyy ....

Thanx for u'r reply !!! Yor'r stuff works perfectly fine ...... just the way i needed it to Smile

Re: How to calculate the cursor Position in a Eclipse graphical editor ?? [message #722636 is a reply to message #646602] Tue, 06 September 2011 11:39 Go to previous messageGo to next message
karthick9686@gmail.com Missing nameFriend
Messages: 41
Registered: July 2011
Member
hi could you please display the code of how to make cut copy and paste in an gef editor. in am having an hasrd time doing it. it would be helpfull if u can send it also. karthick9686@gmail.com
Re: How to calculate the cursor Position in a Eclipse graphical editor ?? [message #1702128 is a reply to message #646916] Mon, 20 July 2015 08:22 Go to previous message
Pooja Naik is currently offline Pooja NaikFriend
Messages: 1
Registered: July 2015
Junior Member
Hi,

Where do we add that setCursorLocation and from where is it called? I was trying to add the same in Edit part. It didn't work.
Previous Topic:Vertical alignment of text
Next Topic:Moving bend points with source and target
Goto Forum:
  


Current Time: Thu Apr 25 12:52:27 GMT 2024

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

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

Back to the top