Snap Objects to Each Other
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- VIP Livecode Opensource Backer
- Posts: 296
- Joined: Wed May 02, 2012 12:23 pm
- Location: New York
- Contact:
Snap Objects to Each Other
Hi folks,
This is not a question, rather an answer; well kinda
Peter asked in the list for a solution to snap objects which are moved and/or resized.
Since, I don't use dropbox or any other file sharing service;
I found suitable to post the stack here.
Also, some of you may find my code useful.
It's not without drawbacks, actually there are many.
But it's a quick attempt, please feel free to change it in anyway or improve and use it.
Best,
~ Ender Nafi
This is not a question, rather an answer; well kinda
Peter asked in the list for a solution to snap objects which are moved and/or resized.
Since, I don't use dropbox or any other file sharing service;
I found suitable to post the stack here.
Also, some of you may find my code useful.
It's not without drawbacks, actually there are many.
But it's a quick attempt, please feel free to change it in anyway or improve and use it.
Best,
~ Ender Nafi
~... together, we're smarter ...~
__________________________________________
macOS Sierra • LiveCode 7 & xCode 8
__________________________________________
macOS Sierra • LiveCode 7 & xCode 8
-
- Posts: 3
- Joined: Mon Aug 26, 2013 6:49 pm
Re: Snap Objects to Each Other
Ender,
This is great. Thanks!!!!
I made modifications to the script (stack attached) for my particular application (I'm working with rows of buttons):
1. buttonActive snaps to buttonListener--buttonListener never moves
2. Once snapping has occurred, buttonListener still doesn't move
3. I've removed the snapping to tops and bottoms--I don't want that for what I'm doing
Now, can there be multiple listening buttons? I'm thinking that while the active button is being dragged, it periodically checks a list of possible listening buttons to see if any one of them has met the close enough criteria--then designates that one as the listener.
Peter
This is great. Thanks!!!!
I made modifications to the script (stack attached) for my particular application (I'm working with rows of buttons):
1. buttonActive snaps to buttonListener--buttonListener never moves
2. Once snapping has occurred, buttonListener still doesn't move
3. I've removed the snapping to tops and bottoms--I don't want that for what I'm doing
Now, can there be multiple listening buttons? I'm thinking that while the active button is being dragged, it periodically checks a list of possible listening buttons to see if any one of them has met the close enough criteria--then designates that one as the listener.
Peter
- Attachments
-
- snapButton2.zip
- (4.34 KiB) Downloaded 327 times
-
- VIP Livecode Opensource Backer
- Posts: 4005
- Joined: Sun Jan 07, 2007 9:12 pm
- Location: Bochum, Germany
Re: Snap Objects to Each Other
Hi Ender,
this is a beautiful stack, thank you. Lots of good stuff in it.
Kind regards
Bernd
this is a beautiful stack, thank you. Lots of good stuff in it.
Kind regards
Bernd
-
- VIP Livecode Opensource Backer
- Posts: 296
- Joined: Wed May 02, 2012 12:23 pm
- Location: New York
- Contact:
Re: Snap Objects to Each Other
Bernd,
That's very kind of you, thanks.
I know it's a bulky code but that's me learning day by day.
Peter et al.,
I added functionality for multiple listeners.
It wasn't an easy task, at least for me; but it's fun to deal with it
There are still many issues, feel free to dive in to pinpoint and hopefully fix them.
Check the comments for those which I've noticed.
Btw, I've changed the stack's name to a cooler one
This is for general use: And this is for Peter, adjusted for that 3 items above: This is just a stripped out and a bit altered version of magnetObjects.
Peter,
I wouldn't use that code as it is.
Since it's an alteration of the above stack, it has more issues.
Try creating a dedicated script for your needs using my script's concept.
That is if you find it useful
Hope it helps some of you...
Best,
~ Ender Nafi
That's very kind of you, thanks.
I know it's a bulky code but that's me learning day by day.
Peter et al.,
I added functionality for multiple listeners.
It wasn't an easy task, at least for me; but it's fun to deal with it
There are still many issues, feel free to dive in to pinpoint and hopefully fix them.
Check the comments for those which I've noticed.
Btw, I've changed the stack's name to a cooler one
This is for general use: And this is for Peter, adjusted for that 3 items above: This is just a stripped out and a bit altered version of magnetObjects.
Peter,
I wouldn't use that code as it is.
Since it's an alteration of the above stack, it has more issues.
Try creating a dedicated script for your needs using my script's concept.
That is if you find it useful
Hope it helps some of you...
Best,
~ Ender Nafi
~... together, we're smarter ...~
__________________________________________
macOS Sierra • LiveCode 7 & xCode 8
__________________________________________
macOS Sierra • LiveCode 7 & xCode 8
-
- VIP Livecode Opensource Backer
- Posts: 2718
- Joined: Sat Dec 22, 2007 5:35 pm
- Location: Genève
- Contact:
Re: Snap Objects to Each Other
Hi Ender,
Simple, elegant... Epicurian
Congratulation
kind regards
Jean-Marc
Simple, elegant... Epicurian
Congratulation
kind regards
Jean-Marc
https://alternatic.ch
-
- VIP Livecode Opensource Backer
- Posts: 296
- Joined: Wed May 02, 2012 12:23 pm
- Location: New York
- Contact:
Re: Snap Objects to Each Other
Epicurean?
That made my day, thank you
The problem is, Jean-Marc,
that I never was able to get things done in 100%.
Even in my school years, my grades were 85 ~ 95 {that's B+ in US system, I guess}.
No less, no more.
This stack isn't different in these manners.
Making something absolutely perfect requires just too much effort and IQ
~ Ender
That made my day, thank you
The problem is, Jean-Marc,
that I never was able to get things done in 100%.
Even in my school years, my grades were 85 ~ 95 {that's B+ in US system, I guess}.
No less, no more.
This stack isn't different in these manners.
Making something absolutely perfect requires just too much effort and IQ
~ Ender
~... together, we're smarter ...~
__________________________________________
macOS Sierra • LiveCode 7 & xCode 8
__________________________________________
macOS Sierra • LiveCode 7 & xCode 8
-
- VIP Livecode Opensource Backer
- Posts: 2718
- Joined: Sat Dec 22, 2007 5:35 pm
- Location: Genève
- Contact:
Re: Snap Objects to Each Other
Hi Ender,
I suspect it is also accept that it is not perfect yet
You may see an example about wide checkbox in this thread
http://forums.runrev.com/phpBB2/viewtop ... 49&t=14346
Best regards
Jean-Marc
It is often difficult to decide when the application is finishedthat I never was able to get things done in 100%.
I suspect it is also accept that it is not perfect yet
You may see an example about wide checkbox in this thread
http://forums.runrev.com/phpBB2/viewtop ... 49&t=14346
Best regards
Jean-Marc
https://alternatic.ch