Wish 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...

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

Because the onInterceptTouchEvent executed before the OnTouch event, is very important to manipulate this in order to have a REAL sliding panel, with no tricks (onTop transparent, listeners to all children views etc).
Can you please check it out, and if it's possible, to give an interface for this event in Panels?

Thank you.
 

keso

Member
Licensed User
You should use this library: [Lib] Gesture Detector
Hmmmm...I think there is the same problem with this library too...
Scenario: You have a transparent top panel, a BasePanelHost (which contains the BasePanel), BasePanel (which contains the pages (Panels) )
- You can catch the Down event on transparent top panel, and pass it to the BasePanelHost . (everything ok till now..)
- When a Move Action happens, it will not be detected because you have passed the events to BasePanelHost (returning False in the previous step)
If we don't Return False, in the Down action, then we cannot have events on the child views...

Have you ever get this to work with this library? Can u please give me an example?

I think that the only way is to catch the event BEFORE....that's why I asked for the onInterceptTouchEvent...
 

Informatix

Expert
Licensed User
Longtime User
Hmmmm...I think there is the same problem with this library too...
Scenario: You have a transparent top panel, a BasePanelHost (which contains the BasePanel), BasePanel (which contains the pages (Panels) )
- You can catch the Down event on transparent top panel, and pass it to the BasePanelHost . (everything ok till now..)
- When a Move Action happens, it will not be detected because you have passed the events to BasePanelHost (returning False in the previous step)
If we don't Return False, in the Down action, then we cannot have events on the child views...

Have you ever get this to work with this library? Can u please give me an example?

I think that the only way is to catch the event BEFORE....that's why I asked for the onInterceptTouchEvent...
Did you look at the examples of the library? I show how to send a motion event occuring in a panel to another panel.
 

keso

Member
Licensed User
Did you look at the examples of the library? I show how to send a motion event occuring in a panel to another panel.
Hi Infomatrix (nice job with the library BTW...),
yes I saw the examples..maybe I missunderstood something, but if you include child views in the receiver panel, then in order to let them function normaly, you cannot use the motion to move the panel (the receiver panel). Also, if you try to use the "Drag" event it isn't working if the touch event was used to send an Action "Down"...
 
Last edited:

Informatix

Expert
Licensed User
Longtime User
Hi Infomatrix (nice job with the library BTW...),
yes I saw the examples..maybe I missunderstood something, but if you include child views in the receiver panel, then in order to let them function normaly, you cannot use the motion to move the panel (the receiver panel). Also, if you try to use the "Drag" event it isn't working if the touch event was used to send an Action "Down"...
In the Dispatch example, I pass all touch events from a panel to another, which ignores them and passes them to the activity. You can consider the second panel and the activity as children and the first panel as a dispatcher. The dispatcher looks at all motion events. If it considers that a motion event has to be handled at the child level, it delegates the event to the child with PassTouchEventTo, but it continues to see all motion events if you return True in its Touch event handler. You can do any gesture, it does not matter. The only inconvenience is that you are in the coordinate system of the dispatcher.
 

keso

Member
Licensed User
In the Dispatch example, I pass all touch events from a panel to another, which ignores them and passes them to the activity. You can consider the second panel and the activity as children and the first panel as a dispatcher. The dispatcher looks at all motion events. If it considers that a motion event has to be handled at the child level, it delegates the event to the child with PassTouchEventTo, but it continues to see all motion events if you return True in its Touch event handler. You can do any gesture, it does not matter. The only inconvenience is that you are in the coordinate system of the dispatcher.
Thank you for the quick reply.
I've attached a minimal example, in which I have 2 issues...
1) the scrolling panel only scrolls if you click on a child view
2) child views that added with the designer, do not fire events!
If you have the time, please take a look, and tell me what am I doing wrong.
 

Attachments

  • test_slide-2.zip
    43.9 KB · Views: 203

Informatix

Expert
Licensed User
Longtime User
Thank you for the quick reply.
I've attached a minimal example, in which I have 2 issues...
1) the scrolling panel only scrolls if you click on a child view
2) child views that added with the designer, do not fire events!
If you have the time, please take a look, and tell me what am I doing wrong.
I don't have the time to debug your code. I just try to explain what a dispatcher can do for you. It can:
- block events so no child sees them (you just return true in the touch event);
- pass an event to a child and continue to monitor all incoming events (you call PassTouchEventTo and return true);
- pass an event to a child and stop monitoring the following touch events for the child (you call PassTouchEventTo and return false, so the child is now the event handler).
 

keso

Member
Licensed User
I didn't want you to debug my code. it was just an example.
The above explanation is enough for me!
thank you very much!
 
Top