DModelPanel Dragging

I’m trying to make it so you can drag a DModelPanel, however I am having problems with the DModelPanel staying/getting the position of the cursor.

[lua]
local x, y = dragicon:GetPos()
local mx, my = gui.MousePos()

			dragicon:SetPos( mx - x, my - y )

[/lua]

That is the closest I have come to for the DModelPanel to actually get the correct position of the cursor, even then it’s dodgy. Have also tried mx and my, but the DModelPanel’s position seems to go away from the cursor.

Is there a calculation for the DModelPanel to actually stay with the cursor?

tl;dr The DModelPanel doesen’t get the gui mouse position properly.

You should try **[Panel.CursorPos

http://wiki.garrysmod.com/favicon.ico](wiki.garrysmod.com/?title=Panel.CursorPos)**

That just makes the DModelPanel go to the opposite screen side of the cursor.

I’m using

[lua]local mx, my = gui.MousePos()
dragicon:SetPos( mx, my )
[/lua]

And It’s appearing like the top:

http://img697.imageshack.us/img697/1153/90868270.jpg

I want it to be positioned like the bottom version.

[lua]local mx, my = gui.MousePos()
dragicon:SetPos( mx - ( dragicon:GetWide() * 0.5 ), my - ( dragicon:GetTall() * 0.5 ) )
[/lua]

That what you want?

Thanx babe