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: 98
Registered: March 2010
Location: Hyderabad
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 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
Previous Topic:seperating label text and image in a label
Next Topic:Draw2D Label preferred size
Goto Forum:
  


Current Time: Thu Dec 18 11:38:21 GMT 2014

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

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