Mouse dragging

Post your Gambas programming questions here.
Post Reply
User avatar
cogier
Site Admin
Posts: 1118
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Mouse dragging

Post by cogier »

When I drag an image on the screen the mouse is positioned top left just outside the image. Is there a way to get the mouse cursor to be within the image being dragged?
User avatar
BruceSteers
Posts: 1523
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Mouse dragging

Post by BruceSteers »

Before calling the object.Drag() method you set Drag.IconX
Drag.IconY

I used this..
Public sub MyObject_MouseMove()
If Mouse.Left then
Drag.IconX = Mouse.ScreenX - Last.ScreenX
Drag.IconY = Mouse.ScreenY - Last.ScreenY
Drag.Icon = hDragPicture
Last.Drag(sData, "text/plain")
Endif
End


That made the mouse stay in the position it was at when the object was clicked.
If at first you don't succeed , try doing something differently.
BruceS
User avatar
cogier
Site Admin
Posts: 1118
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Mouse dragging

Post by cogier »

Thanks Bruce, that did the trick. I had tried the IconX and IconY but couldn't get them to work as I put them in the wrong place.
Post Reply