snap to grid

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
admin12
Posts: 412
Joined: Wed May 11, 2011 9:47 am

snap to grid

Post by admin12 » Thu Aug 11, 2011 12:50 am

Now that I am working on Groove Blox, I need to implement a snap to grid system.
I am also utilizing tracks. I need to figure out how to add/delete tracks (right now, I am using a data grid - in form mode - have a check box and everything that would constitute a track grouped). I assume I just copy the group and delete the selected tracks? Each track needs to be a audio player so it can play back the groove blox.

So, the user will drag and drop a colored rectangle (that also needs to be figured out) into the track in question and I need the rectangle to SNAP to the previous rectangle, if any. If none exist, then it snaps to a placeholder rectangle I put in there. I will eventually hide the placeholder rectangle so all you see are the blocks.

How would I go about setting up the snap to grid?

Mike

admin12
Posts: 412
Joined: Wed May 11, 2011 9:47 am

Re: snap to grid

Post by admin12 » Thu Aug 11, 2011 3:33 pm

Anyone?

Mike

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Re: snap to grid

Post by bn » Thu Aug 11, 2011 6:30 pm

Hi Mike,

try this as one way of doing some sort of 'snap' in a button script. Obviously this could be adapted to a different location.

Code: Select all

on mouseDown
   grab me
end mouseDown

on mouseUp
   set the left of me to item 1 of the loc of this card
end mouseUp

on mouseRelease
   mouseUp
end mouseRelease
Kind regards

Bernd

admin12
Posts: 412
Joined: Wed May 11, 2011 9:47 am

Re: snap to grid

Post by admin12 » Thu Aug 11, 2011 6:55 pm

Close.
I only want to grab ONE copy and have the user drag and drop it into place - into place means on one of the tracks. It should SNAP into place to the left of the previous block (unless there are no blocks. I can make a line to snap to so there is something to the left of the snap point.

Mike

Post Reply