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?
 

Star-Dust

Expert
Licensed User
Longtime User
On what view do you have to intercept these events?

If it were a panel it would be like this
B4X:
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

Star-Dust

Expert
Licensed User
Longtime User
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

Star-Dust

Expert
Licensed User
Longtime User
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:
Public Sub ScrollView_ScrollChanged (OffsetX As Int, OffsetY As Int)
   
End Sub
 
Upvote 0

Semen Matusovskiy

Well-Known Member
Licensed User
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

giagia

Member
Licensed User
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

giagia

Member
Licensed User
When you scroll the ScrollView, this event raises
B4X:
Public Sub ScrollView_ScrollChanged (OffsetX As Int, OffsetY As Int)
  
End Sub
This solution it's ok but OffsetX is always to 0. why? I need to capture horizontal movement ( right to left, and left to right)
 
Upvote 0

giagia

Member
Licensed User
i found the solution. I have add Scroolview and capture the movement event with:
B4X:
 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

Semen Matusovskiy

Well-Known Member
Licensed User
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

  • s24.zip
    2.8 KB · Views: 153
Upvote 0
Top