Drag then lock?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- Posts: 56
- Joined: Sat Jun 20, 2009 2:41 pm
Drag then lock?
I've been playing around with the "on mousedown grab me" command so I can drag a box, button or whatever at runtime.
Is there a way to have an image of a lock (or whatever) that once I'm done dragging things all over the screen I can lock everything into place?
Thanks
Patrick
Is there a way to have an image of a lock (or whatever) that once I'm done dragging things all over the screen I can lock everything into place?
Thanks
Patrick
Drag then lock?
Patrick,
Here is one way to accomplish what you want:
1) Create a global variable to indicate the lock/unlock state.
2) Put something like this into the objects you want to move:
3) Add a lock graphic with the following script:
HTH,
Ed
Here is one way to accomplish what you want:
1) Create a global variable to indicate the lock/unlock state.
2) Put something like this into the objects you want to move:
Code: Select all
on mouseDown
global moveable
if moveable then grab me
end mouseDown
Code: Select all
on mouseUp
global moveable
put false into moveable
set the vis of img "unlock" to false
set the vis of img "lock" to true
end mouseUp
Ed
Re: Drag then lock?
Hi.
Since the grab command allows a "mouseUp" message to pass to the control of interest once you "release" the grab sequence, simply set the locLoc of the control to true.
Craig
Since the grab command allows a "mouseUp" message to pass to the control of interest once you "release" the grab sequence, simply set the locLoc of the control to true.
Craig
Re: Drag then lock?
It just occurred to me. Did you mean that once the control has been moved, it cannot be moved again by any means? Including another grab command?
If so, then Ed's offering above is a good one, disabling the grab command entirely based on some flag or property.
Craig
If so, then Ed's offering above is a good one, disabling the grab command entirely based on some flag or property.
Craig
-
- Livecode Opensource Backer
- Posts: 10099
- Joined: Fri Feb 19, 2010 10:17 am
Re: Drag then lock?
Well, I suppose it was worth a try.
- -
HOWEVER . . .
By having this in the graphic object script:
and this in the cardScript:
where fld "newCODE" contains this:
everything is just dandy, and very simple indeed. 

- -
HOWEVER . . .
By having this in the graphic object script:
Code: Select all
on mouseDown
grab me
end mouseDown
Code: Select all
on mouseUp
set the script of grc "OCT" to fld "newCODE"
end mouseUp
Code: Select all
on mouseDown
---do nix
end mouseDown
on mouseUp
---do nix
end mouseUp

- Attachments
-
- Drag n Lock.livecode.zip
- Here's the stack.
- (1.12 KiB) Downloaded 209 times