PDA

View Full Version : How can I drag the dialog window?


Jausn
05-19-2009, 02:51 AM
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:#()

floopyb
05-19-2009, 03:27 AM
well for one thing you should send the mouse move pos to the function as it is erroring on pos not being in scope.
And maybe set mouseDown to false initially.
Still dosent work too well though!
try (destroydialog posChangeTest) catch()
rollout posChangeTest "Pos Change"
(
button bt1 "Button1"
button bt2 "Button2"

local mouseDown = false

fn moveRollout pos =
(
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 pos
)

createDialog posChangeTest style:#()

Jausn
05-19-2009, 04:39 AM
I found it still didn't work.

So how shall we do?

Jausn
05-19-2009, 05:09 AM
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?

floopyb
05-19-2009, 06:15 AM
he did a bit more than that, but Im not sure why it worked... Something to do with getting rid of the function maybe?

Ruramuq
05-19-2009, 06:29 AM
I use the same for my scripts, The pos of the mouse must be saved once to get it relative to the dialog

Jausn
05-20-2009, 03:29 AM
I use the same for my scripts, The pos of the mouse must be saved once to get it relative to the dialog

I've thought about it much and I agree with you!

Gravey
05-20-2009, 12:20 PM
Also in your original script you had written:if mouseDown = true dowhen it should be if mouseDown == true do
-- note the double equals sign!

Jausn
05-21-2009, 07:35 AM
Also in your original script you had written:if mouseDown = true dowhen it should be if mouseDown == true do
-- note the double equals sign!

Thank you!
Yeah,you were right.But what you said seems not to be the big issue.

Gravey
05-21-2009, 08:40 AM
Thank you!
Yeah,you were right.But what you said seems not to be the big issue.yea just thought i'd throw it in there anyway for future reference

CGTalk Moderation
05-21-2009, 08:40 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.