Stop 'grab me' when object gets outside of another object
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Stop 'grab me' when object gets outside of another object
I have a button inside big graphic rectangle. Button has 'grab me' command so when user click on it, he can move the button. But what I want to do is when that button reaches the outside of that rectangle, the grab command stops (so user can't move the button any further from the borders of that rectangle graphic).
I figured out how I can see when the button is outside of the border, but I have no idea how to stop that 'grab me' command when it's outside. Any ideas?
I figured out how I can see when the button is outside of the border, but I have no idea how to stop that 'grab me' command when it's outside. Any ideas?
Re: Stop 'grab me' when object gets outside of another objec
Hi croivo,
the trick is to NOT use "grab me"
Check Scotts website for a wonderful demo stack:
http://www.tactilemedia.com
Topright click -> Software
Topright click -> See all tutorials >>
Scroll down to -> Drag sampler
And the rest of the stacks aren't too shabby, too!
Best
Klaus
the trick is to NOT use "grab me"

Check Scotts website for a wonderful demo stack:
http://www.tactilemedia.com
Topright click -> Software
Topright click -> See all tutorials >>
Scroll down to -> Drag sampler
And the rest of the stacks aren't too shabby, too!

Best
Klaus
Re: Stop 'grab me' when object gets outside of another objec
Exactly what I'm looking for! Thanks!
-
- Livecode Opensource Backer
- Posts: 10102
- Joined: Fri Feb 19, 2010 10:17 am
Re: Stop 'grab me' when object gets outside of another objec
Certainly with GRAB you are going to have some problems.
If you try to drag the red blob in my example, you will
be able to drag it outwith the circle. If you mouseUp while any of it
is touching any of the blue border it will be subsequently immovable.
If you try to drag the red blob in my example, you will
be able to drag it outwith the circle. If you mouseUp while any of it
is touching any of the blue border it will be subsequently immovable.
Last edited by richmond62 on Sat Feb 07, 2015 2:10 pm, edited 1 time in total.
Re: Stop 'grab me' when object gets outside of another objec
Got it, thanks richmond62!
Re: Stop 'grab me' when object gets outside of another objec
Let me ask another question in this topic... So when user is dragging the button, I want buttons to snap to the 2 graphic lines if the button is 30px far from that line.
Here is sketch: I used this code:
However, that doesn't looks like best solution... It's all laggy 
Here is sketch: I used this code:
Code: Select all
put the mouseloc into mouseLocation
if (item 1 of mouseLocation < the left of graphic "vLine" + 40) and (item 1 of mouseLocation > the left of graphic "vLine" - 40) then
put the width of me into myWidth
divide myWidth by 2
set the left of me to (the left of graphic "vLine" - myWidth)
else if (item 2 of mouseLocation < the top of graphic "hLine" + 40) and (item 2 of mouseLocation > the top of graphic "hLine" - 40) then
put the height of me into myHeight
divide myHeight by 2
set the top of me to (the top of graphic "hLine" - myHeight)
else
end if
