"Snapping" method

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

"Snapping" method

Peter Bogdanoff
Hi,

Before I go ahead and try to reinvent the wheel, does anyone know of a method for this:

I have 2 or more buttons separated on a card. I drag one around, or resize it. When the border of that button gets close to the border of another button (like within 5 pixels), the dragged button is magnetically attracted--snapped--to the second button, so that its border attaches to the border of the other button, their borders aligning--the right of one aligning with the left of the other.

I see that there is a grid setting in the LiveCode preferences that controls this kind of motion when controls are moved with the mouse, but I don't want controls to align to an arbitrary grid but to each other. (The reason for this is that there is an image underneath that the buttons are being aligned over and that can be at any pixel on the card.)

Thanks for any advice...

Peter Bogdanoff
UCLA

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: "Snapping" method

BNig
Hi Peter,

in menu "View" uncheck "Grid", that lets you move controls without snapping to the grid.

if you want to visualize the grid and easily control it, (including turning it off) have a look at
http://livecodeshare.runrev.com/stack/757/GridDrawer

Kind regards
Bernd
Reply | Threaded
Open this post in threaded view
|

Re: "Snapping" method

enderNafi
In reply to this post by Peter Bogdanoff
Peter hi,

This is actually Bernd’s or Scott’s expertise,
but I wanted to give it a shot.

I don’t use dropbox, google drive or any other file sharing service.
So, I uploaded a sample stack to the forums:
http://forums.runrev.com/viewtopic.php?f=22&t=18910#p95292

It’s a quick attempt and has many, many drawbacks.
I’m sure there are more elegant ways to accomplish this.

But it’s a start, hope you find it useful.


Best,

~ Ender


From: Peter Bogdanoff Peter Bogdanoff
Reply: Peter Bogdanoff [hidden email]
Date: January 25, 2014 at 10:11:30
To: How to use LiveCode [hidden email]
Subject:  "Snapping" method  
Hi,  

Before I go ahead and try to reinvent the wheel, does anyone know of a method for this:  

I have 2 or more buttons separated on a card. I drag one around, or resize it. When the border of that button gets close to the border of another button (like within 5 pixels), the dragged button is magnetically attracted--snapped--to the second button, so that its border attaches to the border of the other button, their borders aligning--the right of one aligning with the left of the other.  

I see that there is a grid setting in the LiveCode preferences that controls this kind of motion when controls are moved with the mouse, but I don't want controls to align to an arbitrary grid but to each other. (The reason for this is that there is an image underneath that the buttons are being aligned over and that can be at any pixel on the card.)  

Thanks for any advice...  

Peter Bogdanoff  
UCLA  

_______________________________________________  
use-livecode mailing list  
[hidden email]  
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:  
http://lists.runrev.com/mailman/listinfo/use-livecode 
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
_________________________________________

Mac OS X 10.9.1 • LiveCode 6.5.1 & xCode 5.0.1
Reply | Threaded
Open this post in threaded view
|

Re: "Snapping" method

BNig
In reply to this post by BNig
Hi Peter,

reading Ender's post I realize that I misunderstood you completely.

Sorry for that.

Kind regards
Bernd
Reply | Threaded
Open this post in threaded view
|

Re: "Snapping" method

Peter Bogdanoff
Thanks Bernd. I'll look at GridDrawer. I didn't even know about the grid until I started messing with this problem--didn't know why when you drag controls around they seemed hard to position exactly--they were snapping to the default 2-pixel hidden grid.

And Ender--this is great. Thanks!!!!

I made modifications to the script (modified stack is in the forum) for my particular application (I'm working with rows of buttons):
http://forums.runrev.com/viewtopic.php?f=22&t=18910&p=95304#p95304

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. This would allow me to lay in rows of snapped buttons.

Peter


On Jan 25, 2014, at 5:49 AM, Ender Nafi Elekcioglu wrote:

> Peter hi,
>
> This is actually Bernd’s or Scott’s expertise,
> but I wanted to give it a shot.
>
> I don’t use dropbox, google drive or any other file sharing service.
> So, I uploaded a sample stack to the forums:
> http://forums.runrev.com/viewtopic.php?f=22&t=18910#p95292
>
> It’s a quick attempt and has many, many drawbacks.
> I’m sure there are more elegant ways to accomplish this.
>
> But it’s a start, hope you find it useful.
>
>
> Best,
>
> ~ Ender
>
>
> From: Peter Bogdanoff Peter Bogdanoff
> Reply: Peter Bogdanoff [hidden email]
> Date: January 25, 2014 at 10:11:30
> To: How to use LiveCode [hidden email]
> Subject:  "Snapping" method
>> Hi,
>>
>> Before I go ahead and try to reinvent the wheel, does anyone know of a method for this:
>>
>> I have 2 or more buttons separated on a card. I drag one around, or resize it. When the border of that button gets close to the border of another button (like within 5 pixels), the dragged button is magnetically attracted--snapped--to the second button, so that its border attaches to the border of the other button, their borders aligning--the right of one aligning with the left of the other.
>>
>> I see that there is a grid setting in the LiveCode preferences that controls this kind of motion when controls are moved with the mouse, but I don't want controls to align to an arbitrary grid but to each other. (The reason for this is that there is an image underneath that the buttons are being aligned over and that can be at any pixel on the card.)
>>
>> Thanks for any advice...
>>
>> Peter Bogdanoff
>> UCLA
>>
>> _______________________________________________
>> use-livecode mailing list
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode

>

On Jan 25, 2014, at 6:13 AM, BNig wrote:

> Hi Peter,
>
> reading Ender's post I realize that I misunderstood you completely.
>
> Sorry for that.
>
> Kind regards
> Bernd
>
>
>
> --
> View this message in context: http://runtime-revolution.278305.n4.nabble.com/Snapping-method-tp4675046p4675055.html
> Sent from the Revolution - User mailing list archive at Nabble.com.
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode