Android Question In 2023 with B4XPages cross platform, where to start with gestures/touch?

scGuy

Member
Licensed User
I first saw B4X years ago and reconnecting with it now, I can only say it has been getting better and better. However when I try to find the correct starting point (these days) with gestures and touch, for B4XPage projects that will be android and iOS, I am having difficulty discovering what the proper method to use should be. In B4A I see a "Gestures" internal library, but not sure what it provides, and not cross platform. I also see the panel has a Touch event, and it seems to give very low level data.

I guess I'm asking for thoughts. If you are starting a new cross platform effort with all of the various B4X tools available today, what is the best path to take to support things like swipe left or right to expose actions like delete, expand collapse content, pull in from left, right, or bottom? I'm not sure what the standard terms are to describe all of the touch actions, but basically all the things that are not clicks or scrolls. I'll keep searching the forums.

Thank you community
 

Shelby

Well-Known Member
Licensed User
Touchy Feely:
Private Sub pnlFastScroll_Touch (Action As Int, X As Float, Y As Float)
    Select Action
        Case 0    'DOWN
            If Y >= pnlFastScrollCursor.Top And Y <= pnlFastScrollCursor.Top + pnlFastScrollCursor.Height Then
                FSY0 = pnlFastScrollCursor.Top
                FSdY = Y - FSY0
                FastScrollActive = True
            End If
        Case 2    'MOVE
            If FastScrollActive = True Then
                Private Top, SV2Top As Int
                Top = Max(Y - FSdY, 0)
                Top = Min(Top, pnlFastScroll.Height - pnlFastScrollCursor.Height)
                pnlFastScrollCursor.Top = Top
                If mFastScrollFixedLabel = False Then
                    lblFastScroll.Top = pnlFastScrollCursor.Top + FscLabelTopDelta
                End If
                SV2Top = Top / FScScale
                SetSV2VerticalScrollPosition(SV2Top)
            End If
        Case 1    'UP
            FScTimer.Enabled = True
    End Select
End Sub
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
It depends on what you are trying to do.

If handling the touch events of a panel is enough then the solution will be simple.
Handling gestures that go over other views is more complicated. It is done in B4A with ViewsEx.CreateTouchPanel and B4i with native gesture recognizer.
You can see such code inside B4XDrawer library.
 
Upvote 0
Top