"Snapping" method

Peter Bogdanoff bogdanoff at me.com
Sun Jan 26 13:34:01 EST 2014


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 bogdanoff at me.com
> Date: January 25, 2014 at 10:11:30
> To: How to use LiveCode use-livecode at lists.runrev.com
> 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 
>> use-livecode at lists.runrev.com 
>> 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
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode




More information about the use-livecode mailing list