How can I drag the dialog window?

Hello everyone!

How can I drag the dialog, I mean click down left button on the title bar then move mouse to change the position of the dialog, via moving the mouse within the dialog client window?

This is my Script but that doesn't work.

rollout posChangeTest "Pos Change"
(
button bt1 "Button1"
button bt2 "Button2"

local mouseDown

fn moveRollout =
(
SetDialogPos posChangeTest ((mouse.screenpos) - pos)
)

on posChangeTest lbuttondown pos do
mouseDown = true

on posChangeTest lbuttonup pos do
mouseDown = false

on posChangeTest mousemove pos do
if mouseDown = true do
moveRollout()
)

createDialog posChangeTest style:#()

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
ausn's picture

My friend SITT have fixed my

My friend SITT have fixed my script to the following:

try(destroyDialog posChangeTest) catch()
rollout posChangeTest "Pos Change"
(
button bt1 "Close"

local mouseIsDown = false,thePos = [0,0]

on posChangeTest lbuttondown pos do
(mouseIsDown = true ; thePos = pos)
on posChangeTest lbuttonup pos do
mouseIsDown = false
on posChangeTest mousemove pos do if mouseIsDown do
setDialogPos posChangeTest (mouse.screenpos - thePos)

on bt1 pressed do destroyDialog posChangeTest
)
createDialog posChangeTest style:#()

This time it works perfectly.
But why? Why my first script didn’t work? I see that he just created a new variable named thePos and set thePos = pos, and what’s the difference?

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.