Hi All, I’m trying to figure out a way to have objects snap to a grid on the mouseUp. I have a list of TopLeft coordinates. 500,50 500,125 500,200 500,275 400,50 400,125 …
I want the object to snap to the closest topLeft coordinate in the list upon a mouseUp. I was tried subtracting current x and y coordinate from each item in list, but that quickly was getting complicated. on mouseUp put the topLeft of me into tMyLoc put item 1 of tMyLoc into tXLoc put item 2 of tMyLoc into tYLoc put 1 into tItem1 put 1 into tItem2 put 1 into x repeat for number of lines in cd fld 1 put item tItem1 of line x of cd fld 1 into tXTarget put item tItem2 of line x of cd fld 1 into tYTarget put the abs of (tXTarget - tXLoc) & "," after tCoords put the abs of (tYTarget - tYLoc) & return after tCoords add 1 to x end repeat put "My Current Loc:" && tMyLoc after tCoords answer tCoords end mouseUp on MouseDown Grab me end MouseDown Interesting it appears the smallest abs result of the subtraction seems to be the closes x coord listed. But that only gets me half way there. I thought I’d throw it out here for suggestions…? Thank you! _______________________________________________ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode