out of boundaries
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- VIP Livecode Opensource Backer
- Posts: 9751
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: out of boundaries
Hi.
Do you mean to prevent them from being dragged off the card window or to be sent somewhere via script control? Or both?
In any case, the answer is yes, but let me know which.
Craig
Do you mean to prevent them from being dragged off the card window or to be sent somewhere via script control? Or both?
In any case, the answer is yes, but let me know which.
Craig
-
- VIP Livecode Opensource Backer
- Posts: 9751
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: out of boundaries
It just occurs to me that this may be more difficult than I thought if you want to use the "grab" command. I do not think any messages are sent when under the control of that command, and that holds until the mouse is released. That may require a bit of testing.
But if you use the "mouseMove" message, then no problem.
Craig
But if you use the "mouseMove" message, then no problem.
Craig
-
- Livecode Opensource Backer
- Posts: 9454
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: out of boundaries
I think if you use the grab command inwith an on mouseDown you
can keep polling the mouse with on mouseStillDown.
-
-
can keep polling the mouse with on mouseStillDown.
Code: Select all
on mouseDown
grab me
end mouseDown
on mouseStillDown
set the idleRate to 5
put the loc of grc "ball" into BLOK
if intersect(grc "ball", img "wall", 10) then
set the moveSpeed to 5000
move grc "ball" to 400,300
end if
end mouseStillDown
- Attachments
-
- Boundary.livecode.zip
- Stack.
- (8.89 KiB) Downloaded 74 times
Last edited by richmond62 on Tue Mar 22, 2022 3:54 pm, edited 1 time in total.
-
- VIP Livecode Opensource Backer
- Posts: 9751
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: out of boundaries
Richmond.
i don't think so.I believe that "grab" is blocking.
Craig
i don't think so.I believe that "grab" is blocking.
Craig
-
- VIP Livecode Opensource Backer
- Posts: 9751
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: out of boundaries
This stack has more holes in it than Albert Hall. It is jerky. But it might prove a concept.
One issue with using the "mouseMove" message is that it is a message. One can outrun it if one drags a control too quickly or too jerkily. This does not happen with using the "grab" command, which takes complete control of the object grabbed, but neither speaks to nor listens to anything going on in the real world while it is in play.
One should only "drag" the button with the mouse up. Not a good idea to click, hold and drag.
Craig
One issue with using the "mouseMove" message is that it is a message. One can outrun it if one drags a control too quickly or too jerkily. This does not happen with using the "grab" command, which takes complete control of the object grabbed, but neither speaks to nor listens to anything going on in the real world while it is in play.
One should only "drag" the button with the mouse up. Not a good idea to click, hold and drag.
Craig
Last edited by dunbarx on Mon Mar 28, 2022 3:44 pm, edited 2 times in total.
-
- Livecode Opensource Backer
- Posts: 9454
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: out of boundaries
GRAB did not block me when I tried that stack out.
-
- VIP Livecode Opensource Backer
- Posts: 9751
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: out of boundaries
I suppose one could use the "grab" command if it is allowable that the user can drag a control off screen entirely. Upon releasing the mouse, that control could be sent back to the edge over which it passed in the first place.
The advantages are that one can drag at any rate without dropping the control. A disadvantage is that the control disappears, not being constrained within the card extent, but only returned from nowhere once the mouse is released. This seems to me wrongHeaded.
Craig
The advantages are that one can drag at any rate without dropping the control. A disadvantage is that the control disappears, not being constrained within the card extent, but only returned from nowhere once the mouse is released. This seems to me wrongHeaded.
Craig
-
- VIP Livecode Opensource Backer
- Posts: 9751
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: out of boundaries
Richmond.
Please tell me how to use your stack. When I dragged the ball off screen, I noticed it shot back at lighting speed out of nowhere, and ended up invisible . How do you find it, or reset it?
Craig
Please tell me how to use your stack. When I dragged the ball off screen, I noticed it shot back at lighting speed out of nowhere, and ended up invisible . How do you find it, or reset it?
Craig
-
- VIP Livecode Opensource Backer
- Posts: 9751
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: out of boundaries
Richmond.
OK, I see if I never release the mouse, then if I bring the ball back into the card the ball still tracks. It does bounce a bit upon crossing the card edge. But if I do release the mouse, of course the ball is left where it was dropped, off screen. I do not think this is what the OP wants.
This seems correct, in that the "grab" command does its thing rather single-mindedly.
The bounce at the border is a problem for me.
Craig
OK, I see if I never release the mouse, then if I bring the ball back into the card the ball still tracks. It does bounce a bit upon crossing the card edge. But if I do release the mouse, of course the ball is left where it was dropped, off screen. I do not think this is what the OP wants.
This seems correct, in that the "grab" command does its thing rather single-mindedly.
The bounce at the border is a problem for me.
Craig
-
- Livecode Opensource Backer
- Posts: 9454
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: out of boundaries
The stack has an image called 'wall' that was made by taking a snapshot of
a graphic rectangle with a border 4 pixels wide and a transparent centre.
Now have a look at the code in the green 'ball' graphic:
1. The idleRate is set to a very low value so mouseStillDown
fires at a rate of 12 times a second.
2. As far as I can tell grab is not blocking mouseStillDown checks.
The 'bounce' is very odd, and I am not sure why that happens, although reducing the moveSpeed does reduce
the effect.
a graphic rectangle with a border 4 pixels wide and a transparent centre.
Now have a look at the code in the green 'ball' graphic:
Code: Select all
on mouseDown
grab me
end mouseDown
on mouseStillDown
set the idleRate to 5
put the loc of grc "ball" into BLOK
if intersect(grc "ball", img "wall", 10) then
set the moveSpeed to 5000
move grc "ball" to 400,300
end if
end mouseStillDown
fires at a rate of 12 times a second.
2. As far as I can tell grab is not blocking mouseStillDown checks.
The 'bounce' is very odd, and I am not sure why that happens, although reducing the moveSpeed does reduce
the effect.
-
- VIP Livecode Opensource Backer
- Posts: 2718
- Joined: Sat Dec 22, 2007 5:35 pm
- Location: Genève
- Contact:
Re: out of boundaries
Hi Friends,
I prefer using mousemove for this task.
Kinds regards
Jean-Marc
I prefer using mousemove for this task.
Kinds regards
Jean-Marc
https://alternatic.ch
-
- Livecode Opensource Backer
- Posts: 9454
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: out of boundaries
Possibly . . .
I moved the script out of the ball and into the card:
I moved the script out of the ball and into the card:
Code: Select all
on mouseMove
set the moveSpeed to 500
move grc "ball" to the mouseLoc
end mouseMove
on mouseStillDown
set the idleRate to 5
if intersect(grc "ball", img "wall", 10) then
set the moveSpeed to 200
move grc "ball" to 400,300
end if
end mouseStillDown
- Attachments
-
- Boundary2.livecode.zip
- Stack.
- (10.3 KiB) Downloaded 64 times
-
- VIP Livecode Opensource Backer
- Posts: 9751
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: out of boundaries
@Jean-Marc
I agree about using "mouseMove".
Your offering is smoother than mine, but your ball does not stop quickly enough at the card edge. Mine does that pretty well, but is not as smooth and is more kludgey. I see you use certain flags to monitor the state and position of the ball. I love flags.
@Samuele. Any of this helping you?
Craig
I agree about using "mouseMove".
Your offering is smoother than mine, but your ball does not stop quickly enough at the card edge. Mine does that pretty well, but is not as smooth and is more kludgey. I see you use certain flags to monitor the state and position of the ball. I love flags.
@Samuele. Any of this helping you?
Craig
Re: out of boundaries
Since I'm making a stack for mobile i don't think dragging an object out of the card is relevant there, so via script I'm gonna share a stack that's not quite on subject but that's where i want to block the objects from getting out.
- Attachments
-
- DragSpeed-boundary.zip
- (3.24 KiB) Downloaded 68 times
Samuele.