Android Question onInterceptTouchEvent implementation

keso

Member
Licensed User
Hi,
I'm trying (without success..) to find a way of implementing the onInterceptTouchEvent overriding from B4A. I want to create a slide-panel menu (or library), and this is a very critical point...
Is there anybody who have accomplished this via Reflector or Javaobject libraries???

in the following links is described how usefull is this method:

http://codetheory.in/understanding-android-input-touch-events/

http://neevek.net/posts/2013/10/13/...ouchEvent-and-onTouchEvent-for-ViewGroup.html

Thank you.
 

mangojack

Well-Known Member
Licensed User
Longtime User
Say you have a Panel in your Activity ..
B4X:
Activity_Create(FirstTime As Boolean)
  Dim Ref1 As Reflector
  Ref1.Target = Panel1
  Ref1.SetOnTouchListener("Panel_Touch") 'event name handling touch
Sub

Private Sub Panel_Touch(ViewTag As Object, Action As Int, X As Float, y As Float, MotionEvent As Object) As Boolean
    Select Action
       Case 0   ' ACTION_DOWN

       Case 1   ' ACTION_UP

       Case 2   ' ACTION_MOVE

    End Select
    Return False
End Sub

For another example see THIS ...
 
Last edited:
Upvote 0

keso

Member
Licensed User
Thanks mangojack for the reply!
If you have time , read again my post (the links inside it), and you'll understand that , setting the OntouchListener doesn't solve the problem.
As you will see, the void onInterceptTouchEvent() is beeing called before the OnTouch event, and there you can decide if you will pass the event to the children views, or
you will keep it for the panel. (by the way, this event is firing only in an android.view.Viewgroup , I think this is the Panel view in B4A).
So.....I will ask again...... Is there any way to implement the Overriding of the onInterceptTouchEvent ?????
 
Upvote 0

mangojack

Well-Known Member
Licensed User
Longtime User
Thanks mangojack for the reply!
If you have time , read again my post (the links inside it), and you'll understand that , setting the OntouchListener doesn't solve the problem.
As you will see, the void onInterceptTouchEvent() is beeing called before the OnTouch event, and there you can decide if you will pass the event to the children views, or
you will keep it for the panel. (by the way, this event is firing only in an android.view.Viewgroup , I think this is the Panel view in B4A).
So.....I will ask again...... Is there any way to implement the Overriding of the onInterceptTouchEvent ?????
my bad .. sorry cannot help you ..
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
From a quick look, it is only possible to set the on touch listener on Listview as an example, doing this using Javaobject does not raise an event for the intercept method. It appears that the method has to be written as part of the class, you will have to put a request in the Wishlist for Erel to consider.
 
Upvote 0

keso

Member
Licensed User
From a quick look, it is only possible to set the on touch listener on Listview as an example, doing this using Javaobject does not raise an event for the intercept method. It appears that the method has to be written as part of the class, you will have to put a request in the Wishlist for Erel to consider.
Thanks stevel05 ....
I think it's time to use the WishList...
 
Upvote 0
Top