[Bug] Touch Events

Sonny

Member
Licensed User
Longtime User
There appears to be some strange behavior with a touch event on an Activity.

If you run my included code, you'll see that when you touch-scroll the panel, in the center of the screen, it will move smoothly, until the displayed horizontal count gets to about 400. Then when you scroll before and past that point, you'll see the box motion noticibly jump, and the counter will also reflect that jump. This action also happens in the vertical direction, around the displayed value of about 200.

I'm using the latest Basic4Android IDE version 2.0.2 - running the code on a Samsung Galaxy Player 5, on Gingerbread 2.3.5.

Anyone else noticing this behavior - or have a fix for this?

Thanks to all, in advance.

>> Sonny <<
 

Attachments

  • Test.zip
    6.8 KB · Views: 253

Erel

B4X founder
Staff member
Licensed User
Longtime User
See the DraggableView class: http://www.b4x.com/forum/basic4android-updates-questions/18395-classes-soon-coming.html#post105519
You should use Reflector.SetOnTouchListener.

Panel_Touch events are sent through the message queue. It works like this due to a change in Android 4.0.3. Without the message queue, the debugger and modal dialogs will crash the application inside a touch event.
What happens in your case is that the panel moves and you are still handling previous events.

The solution is to use Reflector.
 

Roger Garstang

Well-Known Member
Licensed User
Longtime User
I have one device that detects horizontal vs vertical movement with differing accuracy. I made a button out of a label and process the touch events to change the button image. One direction works fine and when I drag outside the button it changes the image and pops it back up. The other direction is smooth on some areas of the screen and jumps around in others. Often times when I drag outside the button in the flawed direction it doesn't change the image and acts like the event just stopped when it jumped and now that my finger is outside the button it still thinks it is inside. If I rotate the device then the opposite direction is jumping. Seems like imperfections in the hardware or there is just more accuracy on one axis.
 

Sonny

Member
Licensed User
Longtime User
Erel,

Thanks for the quick reply.

Switching over to the use of a Class and the Reflector, instead of the built-in events, has made my code more compact and usable. It turns out though that it was NOT a Basic4Android bug that cause the problem! Read my response below to Roger for the cause.

Roger,

After reading your response, I examined my device more closely, and indeed it has a flaw in it. There are two thin "virtural bars" on the screen - one horizontal and one vertical, they cross in the exact center of the screen. They are not visible, but they are there. Whenever I slowly drag ANY item from ANY screen, the behavior I described earlier is exhibited. I never noticed this behavior before - this is the first time I'm coding for this device.

Thanks all for your help. :)

>> Sonny <<
 
Top