iOS Question I need swipe event

giagia

Member
Licensed User
I need to capture event ( swipe, long Press). In b4a I used gesturedetector. how can I do in B4i?
 
On what view do you have to intercept these events?

If it were a panel it would be like this
B4X: Copy
Public Sub Panel_LongClick
   
End Sub

Public Sub Panel_Touch(Action As Int, X As Float, Y As Float)
    Select Action
        Case 0 ' down
           
        Case 1 ' Up
           
        Case 2 ' move / drag
           
    End Select
End Sub

Then it depends exactly what you need to achieve
 
Upvote 0
the view is ScrollView, on it I have line of label
The ScrollView already handles and consumes these events. Why do you need to intercept them?
 
Upvote 0
When a user drag on a element of scrollview(right to left) I need to run a method.
When you scroll the ScrollView, this event raises
B4X: Copy
Public Sub ScrollView_ScrollChanged (OffsetX As Int, OffsetY As Int)
   
End Sub
 
Upvote 0
As I understand, a scrollview holds some child elements (for example, ImageView) and user can drag them.
The easiest solution is to add a panel, which will be a child of RootPanel with maximum z-order index (BringToFront) .
 
Last edited:
Upvote 0
As I understand, a scrollview holds some child elements (for example, ImageView) and user can drag them.
The easiest solution is to add a panel, which will be a child of RootPanel with maximum z-order index (BringToFront) .
my panel need to Scrolldown, I put the scrollview into panel but now I can't capture panel_Touch.
 
Upvote 0
i found the solution. I have add Scroolview and capture the movement event with:
B4X: Copy
 Sub myScrollview_Touch(Action As Int, X As Float, Y As Float)
    Select Action
        Case 0 ' down
       
        Case 1 ' Up
      
        Case 2 ' move / drag
          
            
    End Select
End Sub
 
Upvote 0
Probably, there is a reason to use native gesture recognizer. Not so simple, but not very difficult also.
I made a sample. An app detects swipe left/right and hides corresponding view.
 

Attachments

Upvote 0
Back
Top