Panel Touch event question

khos

Member
Licensed User
Longtime User
Hi there,

I would like to ask for advise on this one, from http://www.b4x.com/forum/basic4andr...9-editable-moveable-text-panel.html#post78873 I took the code:

Sub pnlTest_Touch (Action As Int, X As Float, Y As Float)
X = X-(lblPanelTitle.Width/2)
Y = Y-(lblPanelTitle.Height/2)
If x >= 0 AND x <= pnlTest.Width-lblPanelTitle.Width Then
lblPanelTitle.Left = X
End If
If y >= 0 AND y <= pnlTest.Height-lblPanelTitle.Height Then
lblPanelTitle.Top = Y
End If
End Sub

and it works except it doesn't work as I expect, it seems to work more like a click event..I have to lift my finger each time to make it follow my finger, is there code that can just make a panel follow my finger around as I move the finger around the screen?

X As Float, Y As Float, are those the X,Y coordinates where the finger pressed within the panel?

Any ideas why this might be happening or how to do this?
Thanks
 
You have to add
Code:
return True
at the end so that the touch event will work for all cases (down, move,up)
 
Upvote 0
You have to add
Code:
return True
at the end so that the touch event will work for all cases (down, move,up)

Is this right?...

Code:
Sub pnlTest_Touch (Action As Int, X As Float, Y As Float) as Boolean
   X = X - (lblPanelTitle.Width/2)

   Y = Y - (lblPanelTitle.Height/2)

   If X >= 0 AND X <= pnlTest.Width - lblPanelTitle.Width Then
      lblPanelTitle.Left = X

   End If

   If Y >= 0 AND Y <= pnlTest.Height - lblPanelTitle.Height Then
      lblPanelTitle.Top = Y

   End If

   Return True
End Sub
 
Last edited:
Upvote 0
Back
Top