Simple way to drag a graphic across the screen?- Solved
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Simple way to drag a graphic across the screen?- Solved
What is a simple way to drag a graphic across the screen and drop it, then go get another one?
I have looked in dictionary at the various drag events and tried couple things, but no real success so far.
I little guidance would be great!
Thanks,
David
I have looked in dictionary at the various drag events and tried couple things, but no real success so far.
I little guidance would be great!
Thanks,
David
Last edited by DR White on Fri Sep 08, 2017 6:11 pm, edited 2 times in total.
Re: What is a simple way to drag a graphic across the screen
Sorry to bother anyone. After some more head banging, I did find some info on moving graphics in one of the tutorials. The "Grab" command works great!
-
- VIP Livecode Opensource Backer
- Posts: 9567
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: What is a simple way to drag a graphic across the screen
You might also do something like:
Code: Select all
on mouseMove
set the loc of grc "yourGraphic" to the mouseLoc
end mouseMove
Re: What is a simple way to drag a graphic across the screen
Or a tad more effective:
Code: Select all
on mouseMove x,y
set the loc of grc "yourGraphic" to x,y
end mouseMove
-
- VIP Livecode Opensource Backer
- Posts: 9567
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: What is a simple way to drag a graphic across the screen
Here is another way to move stuff around. On a new card with three buttons, place this in the card script:
Craig
Code: Select all
on mouseMove x,y
if the optionKey is down then
set the xx of this cd to x
set the yy of this cd to y
wait 1
put the xx of this cd - item 1 of the mouseLoc into newX
put the yy of this cd - item 2 of the mouseLoc into newY
repeat with u = 1 to 3
set the loc of btn u to item 1 of the loc of btn u - newX & "," & item 2 of the loc of btn u - newY
end repeat
end if
end mouseMove
Re: What is a simple way to drag a graphic across the screen
Hey, that is cool!
I added "lock screen" for smoother movement.
I added "lock screen" for smoother movement.
Re: What is a simple way to drag a graphic across the screen
Neat stuff for sure Craig =^)
-
- VIP Livecode Opensource Backer
- Posts: 7210
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: What is a simple way to drag a graphic across the screen
How does it differ from the built in move command? You can do the same thing in one line of script. I could be missing something, I didn't actually try it.
Edit - what I missed is that this is dynamic. Gotcha.
Edit - what I missed is that this is dynamic. Gotcha.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
-
- VIP Livecode Opensource Backer
- Posts: 9567
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: What is a simple way to drag a graphic across the screen
Klaus
Lock screen is nice. There is a new message repeatedly sent, after all, and the screen unlocks between those events.
Interestingly, and this surely depends on the speed of the machine, there is a lower limit for the wait time. One tick is just about it for my 3.2 GHz iMac with OS 10.9 and LC 6.7.9. One tick is about 16 milliseconds. Not too much lower than that and the kluge (because that is what this is) will fail.
On the other end, jerkiness appears with wait values above about 3 ticks, lock screen notwithstanding.
I think 2 ticks is best.
Craig
Lock screen is nice. There is a new message repeatedly sent, after all, and the screen unlocks between those events.
Interestingly, and this surely depends on the speed of the machine, there is a lower limit for the wait time. One tick is just about it for my 3.2 GHz iMac with OS 10.9 and LC 6.7.9. One tick is about 16 milliseconds. Not too much lower than that and the kluge (because that is what this is) will fail.
On the other end, jerkiness appears with wait values above about 3 ticks, lock screen notwithstanding.
I think 2 ticks is best.
Craig
-
- VIP Livecode Opensource Backer
- Posts: 9567
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: What is a simple way to drag a graphic across the screen
@Jacque.
What did you mean by "dynamic", or rather, what did you have in mind to move several objects?
Craig
Hi.what I missed is that this is dynamic. Gotcha.
What did you mean by "dynamic", or rather, what did you have in mind to move several objects?
Craig
-
- VIP Livecode Opensource Backer
- Posts: 7210
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: What is a simple way to drag a graphic across the screen
By dynamic I meant that it responds to user drag rather than just a one time move command.
But you could still use mouseMove with the built-in move command with far less scripting.
Or commonly, just set the loc of the object to x, y.
But you could still use mouseMove with the built-in move command with far less scripting.
Code: Select all
on mouseMove x, y
move me to x, y - - or a named target
end mouseMove
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: What is a simple way to drag a graphic across the screen
Thanks so much for all the help!
David
David
-
- VIP Livecode Opensource Backer
- Posts: 9567
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Simple way to drag a graphic across the screen?- Solved
Jacque.
True about the one-liner for one control. But I was moving a handful of controls at the same time.
I was really only interested in how this might be made to work with "mouseMove". The "wait" is essential, to fool the current handler into acting on the initial x,y parameters passed with the message. Those early values have to be stored somewhere BEFORE the wait, so they can be referenced AFTER the wait, when the mouseLoc is different.
It is a kluge, as I said, which is why with a few dozen objects it starts to get jittery.
Craig
True about the one-liner for one control. But I was moving a handful of controls at the same time.
I was really only interested in how this might be made to work with "mouseMove". The "wait" is essential, to fool the current handler into acting on the initial x,y parameters passed with the message. Those early values have to be stored somewhere BEFORE the wait, so they can be referenced AFTER the wait, when the mouseLoc is different.
It is a kluge, as I said, which is why with a few dozen objects it starts to get jittery.
Craig
-
- VIP Livecode Opensource Backer
- Posts: 7210
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: Simple way to drag a graphic across the screen?- Solved
Like this:True about the one-liner for one control. But I was moving a handful of controls at the same time.
Code: Select all
on mouseMove x,y
lock moves
repeat for each item i in tListOfControls -- you'd need to specify these
move control i to x,y
end repeat
unlock moves
end mouseMove
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
-
- VIP Livecode Opensource Backer
- Posts: 9567
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Simple way to drag a graphic across the screen?- Solved
Jacque.
Could not get your handler as written to work. But this almost does:
But it also has problems. With two controls, one moves nicely but the other does not. With more than two, one still does not and the remaining ones are jerky.
Craig
Could not get your handler as written to work. But this almost does:
Code: Select all
on mouseMove x,y
if the optionKey is down then
lock moves
repeat with u = 1 to the number of controls
move control u to x,y
end repeat
unlock moves
end if
end mouseMove
Craig