I've taken the B4A Expandable List demo an attempted to use the GestureDetector library with it. My goal is to use a swipe left to remove an item from the list.
Events are caught but the Sender.Tag field is always the max index. Where as with the normal Panel_Click Sender.Tag is the Index of the element.
So I simply added the GestureDetector under Class Globals
I add the listener in the InsertAtImpl
And my event handlers
Any help on what I've done wrong would be much appreciated.
Modified B4A Expandable List project included in case the problem is more than just me being dumb.
Events are caught but the Sender.Tag field is always the max index. Where as with the normal Panel_Click Sender.Tag is the Index of the element.
So I simply added the GestureDetector under Class Globals
B4X:
Sub Class_Globals
Private GD As GestureDetector
--------- rest same --------
I add the listener in the InsertAtImpl
B4X:
Private Sub InsertAtImpl(Index As Int, Pnl As B4XView, ItemHeight As Int, Value As Object, InitialHeight As Int)
'create another panel to handle the click event
Dim p As B4XView = CreatePanel("Panel")
p.Color = Pnl.Color
Pnl.Color = xui.Color_Transparent
p.AddView(Pnl, 0, 0, sv.ScrollViewContentWidth, ItemHeight)
p.Tag = Index
Log("Initial Index Value: " & p.Tag)
' trying to get gestures on the panel
GD.SetOnGestureListener(p, "Gesture")
And my event handlers
B4X:
Private Sub Gesture_onFling(velocityX As Float, velocityY As Float, MotionEvent1 As Object, MotionEvent2 As Object)
Dim pnl As B4XView = Sender
Log(" onFling velocityX = " & velocityX & ", velocityY = " & velocityY & ", ev1 = " & MotionEvent1 & ", ev2 = " & MotionEvent2)
Log("Item Index: " & pnl.Tag)
End Sub
Private Sub Gesture_onSingleTapConfirmed(X As Float, Y As Float, MotionEvent As Object)
Dim pnl As B4XView = Sender
Log("onSingleTapConfirmed Index: " & pnl.Tag)
PanelClickHandler(Sender)
End Sub
Any help on what I've done wrong would be much appreciated.
Modified B4A Expandable List project included in case the problem is more than just me being dumb.