New topic: drag text into canvas
<http://forums.realsoftware.com/viewtopic.php?t=30538> Page 1 of 1 [ 3 posts ] Previous topic | Next topic Author Message pbart Post subject: drag text into canvasPosted: Sun Oct 18, 2009 6:45 am Joined: Sat Oct 10, 2009 6:40 am Posts: 6 Hi all I am trying to teach myself real basic, and am having a bit of a problem getting mouse coordinates. I have created a sample app with a static text object at the top left of the window (StaticText1), and below it is a canvas (Canvas1). I want to drag the text onto the canvas. In the mousedown for StaticText1: Code:Dim d As DragItem d = NewDragItem(me.left,me.top,me.width,me.height) d.text = me.text d.drag Return True In the mousedrag for StaticText1: Code:dragX = x dragY = y dragX and DragY are global. in the DropObject for Canvas1: Code:dim newx, newy As Integer newx = dragX - 80 //canvas is 80 from top newy = dragY - 6 //Canvas is 6 from left If Obj.TextAvailable then Canvas1.Graphics.DrawString(obj.text,newx,newy) End if When I do the drag and drop the text ends up in a different location to where I drop it. I am going on the assumption that the code in the mouseDrag for staticText1 will give an x,y location with reference 0,0 for the window , the code in the DropObject needs an x,y with reference to 0,0 on the canvas. So subtracting the canvas position from the from the x,y given by the mouseDrag for staticText1 should give me the x,y drop point for the canvas. I am obviously wrong about my assumption, because the drop is not happening where I want it. Can someone give me a few pointers to where I am going wrong. Thanks in advance Paul Top Lazze Post subject: Re: drag text into canvasPosted: Sun Oct 18, 2009 6:53 am Joined: Thu Jul 27, 2006 7:32 am Posts: 87 Location: Esbjerg, Denmark Just of the top of my head, but maybe you should look at the MouseMove event. It returns the x and y coordinates of the mouse, relative to the control. _________________ Why make it simple if it can be made complicated? http://www.laniesoftware.com Top pbart Post subject: Re: drag text into canvasPosted: Sun Oct 18, 2009 7:23 am Joined: Sat Oct 10, 2009 6:40 am Posts: 6 Thanks Lazze I just tried that and it didn't seem to work while the drag was happening. Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 3 posts ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
