Page 1 of 1
Grab (drag an object) only within specific area?
Posted: Mon Dec 18, 2017 10:34 pm
by thatkeith
I'd like to have the user grab and drag a simple object across the card, but constrained to move in just one plane and also within a specific span. Specifically, a vertical line, dragged horizontally across an image, so the user can specify where North is in the image.
In SuperCard I'd probably use 'grab', as in
Code: Select all
grab me within the rect of cd grc "photo"
But of course LiveCode's 'grab' is slightly different. Can anyone point me towards the right way to achieve this here?
k
Re: Grab (drag an object) only within specific area?
Posted: Mon Dec 18, 2017 10:52 pm
by bogs
Huh, without having actually tried it, that looks correct to me. If no one fills it, I'll test it later.
Re: Grab (drag an object) only within specific area?
Posted: Mon Dec 18, 2017 11:27 pm
by FourthWorld
I don't believe LC has added a "within" clause, though Jacque has requested something along those lines:
http://quality.livecode.com/show_bug.cgi?id=4890
Re: Grab (drag an object) only within specific area?
Posted: Mon Dec 18, 2017 11:40 pm
by jmburnod
Hi thatkeith,
Here is a thread about this
http://forums.livecode.com/viewtopic.ph ... t&start=15
and a stack "stMoveControlInsideRect001" here:
http://forums.livecode.com/download/file.php?id=7938
Best regards
Jean-Marc
Re: Grab (drag an object) only within specific area?
Posted: Mon Dec 18, 2017 11:55 pm
by bogs
Actually, there is a within clause Introduced: 1.0, however I think they work slightly differently - and a lot more -
Lc Dictionary wrote:Summary:
Evaluates to true if a point is inside the specified rectangle, false if it is outside.
Examples:
"22,33" is within "22,17,150,200" -- evaluates to true
the mouseLoc is within the rect of this stack
Use the is within operator to determine whether a point is inside a rectangle.
And Jm came up with that quick, good thread.
Re: Grab (drag an object) only within specific area?
Posted: Wed Dec 20, 2017 3:43 am
by bogs
You know, as I thought about this more, a much MUCH simpler solution came to me. Why not just set the picture into a group with its size locked, and a horizontal scroll bar? you could overlay the line on top of the group, moving the scrollbar automatically moves the picture, and it looks just as you described.
