I'm adding drag & drop functionality to my app using Erel's class sample.
I'd like to implement a snap-to grid so that the views somewhat align themselves. For example, a virtual grid line every 5dip horizontally and vertically.
I'm sure I can figure it out, but my solutions sometimes tend to be more complicated than they need to be. So I'm curious if anyone has already done something like this or has an idea on how to incorporate that into the code in Erel's sample.
I'd like to implement a snap-to grid so that the views somewhat align themselves. For example, a virtual grid line every 5dip horizontally and vertically.
I'm sure I can figure it out, but my solutions sometimes tend to be more complicated than they need to be. So I'm curious if anyone has already done something like this or has an idea on how to incorporate that into the code in Erel's sample.
B4X:
Private Sub Panel1_Touch (o As Object, ACTION As Int, x As Float, y As Float, motion As Object) As Boolean
If ACTION = ACTION_DOWN Then
downx = x
downy = y
Else
innerView.Left = innerView.Left + x - downx
innerView.Top = innerView.Top + y - downy
panel1.Left = innerView.Left
panel1.Top = innerView.Top
End If
Return True
End Sub