Drag then lock?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
TodayIsTheDay
Posts: 56
Joined: Sat Jun 20, 2009 2:41 pm

Drag then lock?

Post by TodayIsTheDay » Sat Jun 20, 2009 10:01 pm

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

edljr
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 56
Joined: Sun Oct 26, 2008 6:47 am
Contact:

Drag then lock?

Post by edljr » Mon Jul 13, 2009 5:39 am

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:

Code: Select all

on mouseDown
global moveable
if moveable then grab me
end mouseDown 
3) Add a lock graphic with the following script:

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 
HTH,
Ed

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10320
Joined: Wed May 06, 2009 2:28 pm

Re: Drag then lock?

Post by dunbarx » Tue Dec 24, 2019 3:04 pm

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

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10320
Joined: Wed May 06, 2009 2:28 pm

Re: Drag then lock?

Post by dunbarx » Tue Dec 24, 2019 3:48 pm

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

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Re: Drag then lock?

Post by richmond62 » Fri Dec 27, 2019 12:30 pm

Well, I suppose it was worth a try. :D
-
drag1.jpg
-
HOWEVER . . .

By having this in the graphic object script:

Code: Select all

on mouseDown
   grab me
end mouseDown
and this in the cardScript:

Code: Select all

on mouseUp
   set the script of grc "OCT" to fld "newCODE"
end mouseUp
where fld "newCODE" contains this:

Code: Select all

on mouseDown
---do nix
end mouseDown

on mouseUp
---do nix
end mouseUp
everything is just dandy, and very simple indeed. 8)
Attachments
Drag n Lock.livecode.zip
Here's the stack.
(1.12 KiB) Downloaded 210 times

Post Reply