Android Question Difference between Reflection onTouchEvent and Panel_Touch

pauleffect

Member
Licensed User
Longtime User
Ok, I read a post, this one and my curiosity went over 9000.

I was trying to make my own floating options panel and the "jitter" was through the roof. I even tried using timers to filter out touch events, to animate between drags and whatever.

Then I tried erel's draggable class and boom!

As he used ontouchevent instead of a regular panel_touch, he inserted a comment saying his reason deserved a thread.

I can't believe nobody asked until now. Well, here it goes:

why-meme.png

Looking forward to the answer!
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
See agraham's note about DoEvents / modal dialogs: http://www.b4x.com/android/help/reflection.html#reflector_setontouchlistener

Starting from Android 4.03 it was no longer possible to process the message queue inside some of the events.
DoEvents calls or MsgBox calls cause the app to crash when done during these events.
(Search for: recycled twice to see the errors).

The solution was to send the event to the message queue instead of processing it immediately. This way the developer code was safe as it wasn't executed inside the event.
http://www.b4x.com/android/forum/threads/java-ba-raiseeventfromui.18047/#content

However in the case of Touch event it is not perfect. Your code is not synchronized with the touch events. This causes the movement to be very jumpy, because the panel has already moved when your code executes. So I'm using reflection to add the touch event handle it directly. If you try to put a breakpoint in this sub (which is equivalent to a modal dialog) then the program will crash.
 
Upvote 0

pauleffect

Member
Licensed User
Longtime User
I was going bananas. Literally. And I have to say, after seeing that custom control work, i smelled something fishy. on a dual core(arm as it is, but still) it's unthinkable not to be able to smoothly drag a panel.

thanks, i was looking forward to this!
 
Upvote 0
Top