Catching a drop onto a Gonode in a GoView

I’m trying to catch a drag and drop onto an existing GoNode in a GoView. I’m trying the following code, and it’s not working because the origin of the evt coordinates is (I think) from the app’s form and the origin for the Node coordinates is from the goView.



Does anyone know if the Go library has an intrinsic way to handle this? If not, any suggestions on how to solve with would be greatly appreciated.



Thanks!



nic





protected override IGoCollection DoExternalDrop(DragEventArgs evt)

{



GoLayer oDefaultLayer = this.Document.Layers.Default;

foreach(GoObject oCurrentObj in oDefaultLayer)

{

//Check for drop on top

if( evt.Y > oCurrentObj.Top &&

evt.Y < oCurrentObj.Bottom &&

evt.X > oCurrentObj.Left &&

evt.X < oCurrentObj.Right)

{

//TODO: Handle dropping on another node.

}



}



}

The answer to your question: Point screenPnt = new Point(evt.X, evt.Y); Point viewPnt = view.PointToClient(screenPnt); PointF docPnt = view.ConvertViewToDoc(viewPnt); But you may find it more useful to copy/adapt the code in the OrgCharter sample, that I believe does what you want. Look at the override of DoExternalDrop in OrgCharter\GraphView.cs. It turns out that these calculations, as well as other state, are already gathered for you in the GoView.LastInput object.

That worked. Thanks for the help!