You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by Edvin Syse <ed...@sysedata.no> on 2011/06/07 20:31:00 UTC

Drag and Drop in TreeView - need to convert y coordinate?

My TreeView has a DragSource and DropTarget used to allow moving nodes 
around. In DropTarget#drop, I try to get the node the user dropped on 
like this:

Sequence.Tree.get(getTreeData(), getNodeAt(y))

.. but it seems y is relative to the window, and getNodeAt() expects 
coordinates relative to the component (TreeView). Is there method to 
convert the coordinates, or should I use another approach?

-- Edvin

Re: Drag and Drop in TreeView - need to convert y coordinate?

Posted by Edvin Syse <ed...@sysedata.no>.
Never mind, just found it :)

int relativeY = component.mapPointFromAncestor(getWindow(), 0, y).y;

-- Edvin

Den 07.06.2011 20:31, skrev Edvin Syse:
> My TreeView has a DragSource and DropTarget used to allow moving nodes
> around. In DropTarget#drop, I try to get the node the user dropped on
> like this:
>
> Sequence.Tree.get(getTreeData(), getNodeAt(y))
>
> .. but it seems y is relative to the window, and getNodeAt() expects
> coordinates relative to the component (TreeView). Is there method to
> convert the coordinates, or should I use another approach?
>
> -- Edvin

Re: Drag and Drop in TreeView - need to convert y coordinate?

Posted by Edvin Syse <ed...@sysedata.no>.

Den 07.06.2011 20:41, skrev Chris Bartlett:
> http://apache-pivot-users.399431.n3.nabble.com/Drag-and-Drop-using-a-TreeView-as-the-DropTarget-td2657008.html

Ah, yes, thanks :)

Re: Drag and Drop in TreeView - need to convert y coordinate?

Posted by Chris Bartlett <cb...@gmail.com>.
http://apache-pivot-users.399431.n3.nabble.com/Drag-and-Drop-using-a-TreeView-as-the-DropTarget-td2657008.html

On 8 June 2011 01:31, Edvin Syse <ed...@sysedata.no> wrote:

> My TreeView has a DragSource and DropTarget used to allow moving nodes
> around. In DropTarget#drop, I try to get the node the user dropped on like
> this:
>
> Sequence.Tree.get(getTreeData(), getNodeAt(y))
>
> .. but it seems y is relative to the window, and getNodeAt() expects
> coordinates relative to the component (TreeView). Is there method to convert
> the coordinates, or should I use another approach?
>
> -- Edvin
>