I'm using Erel's DraggableView Class for a drawing program I writing and it is working a treat.
However, I'd like to give the user a little more accurate control over where the views (buttons with images) are finally placed. I've created an up, down, left and right joystick control to allow the user to move them pixel by pixel
(Many thanks to Jaames for inspiration and assistance)
How do I pass the last view dragged from the class back to the main activity to allow me to move it?
I'm sorry if this seems simple but I'm a self taught programmer and sometimes even the most simple things evade me.
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
CallSub2(Main, "LastPressed",innerView) 'added Callsub2 here
Return True
End Sub
Then added the sub to the main activity to pass the view:
B4X:
Sub LastPressed (Innerview As View)
LastView = Innerview
End Su
It is better to only call this sub when Action = ACTION_DOWN. The Touch event can be raised many times and it is better to keep it efficient as possible.