B4A Library [Lib] Gesture Detector

This library adds the detection of standard gestures (press, single-tap, double-tap, long tap, drag, scroll, fling, pinch, rotation) to B4A. Instead of using the Touch events to figure out what the user really did, now you just set 15 different listeners with one line of code and you get the gestures as events with all the useful values (scrolling distance, fling velocity, pinch variation, rotation angle...).
With this library, you can also know easily the pressure or the size of a touch event.

It works with any view.

Note: you have to create an instance of GestureDetector (with Dim) for each view you want to bind to the detector with SetOnGestureListener.

v2.2:
- Freeware.

v2.3:
- I fixed an issue with the boolean value returned by the OnTouch event with some views (e.g. ListView or ScrollView);
- I added a new demo (GD_SwipeLV);
- The OnDown event is now raised before OnDoubleTap.

v2.4:
- I fixed an issue when a view is dragged after one of the pointer is up (delta values were computed according to the pointer 0, not to the remaining pointer).

Incompatible with Android versions < 2.
 

Attachments

  • GestureDetector v2.4.zip
    35.3 KB · Views: 3,007
  • Java source - GestureDetector.zip
    5.5 KB · Views: 1,150
Last edited:

Widget

Well-Known Member
Licensed User
Longtime User
I just discovered The Gesture Detector (v2.4) and it looks incredibly powerful yet simple to use. Congrats on the design. o_O

I am trying to understand one of the demos: GestureDetector_Dispatch. (I am using B4A v7.80 with the emulator)
When I drag within the Red box the Red_onTouch event gets called and returns false to pass control to Activity_Touch, which is fine. I understand that.

This is the log when the red box is dragged and shows the Activity_Touch events as expected:
B4X:
RED_Touch action=0, x=93.1875, y=47.234375, ev=MotionEvent { action=ACTION_DOWN, id[0]=0, x[0]=93.1875, y[0]=47.234375, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=92434, downTime=92434, deviceId=0, source=0x1002 }
ACTIVITY_Touch action=0 (down), x=413.1875, y=347.234375
   ACTIVITY_Touch action=2, x=421.39593505859375, y=369.48968505859375
   ACTIVITY_Touch action=2, x=423.97247314453125, y=376.4143981933594
   ACTIVITY_Touch action=2, x=426.02911376953125, y=380.0436706542969
   ACTIVITY_Touch action=2, x=427.1769104003906, y=381.765380859375
ACTIVITY_Touch action=1 (up), x=427.1769104003906, y=381.765380859375

But when I drag within the green box, GD_Green_OnTouch gets executed and it then calls GD_Red_onTouch using PassTouchEventTo() method. Ok, so far so good. But GD_Red_onTouch still returns false so shouldn't it let Activity_Touch event handle it? But it doesn't. Why not? In other words, why isn't Activity_Touch handling the event after GD_Red_onTouch is called from the GD_Green_onTouch event?

Here are the events that I think should be called: GD_Green_onTouch -> GD_Red_onTouch -> Activity_Touch
But it is only calling: GD_Green_onTouch -> GD_Red_onTouch

A simple drag in the Green box never shows Activity_Touch being called. (Activity_Touch calls are missing)
Remember, GD_Red_onTouch still returns false if called from GD_Green_onTouch event.
B4X:
GREEN_Touch action=0, x=21.15234375, y=12.431640625, ev=MotionEvent { action=ACTION_DOWN, id[0]=0, x[0]=21.152344, y[0]=12.431641, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=7810660, downTime=7810660, deviceId=0, source=0x1002 }
RED_Touch action=0, x=21.15234375, y=12.431640625, ev=MotionEvent { action=ACTION_DOWN, id[0]=0, x[0]=51.152344, y[0]=212.43164, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=7810660, downTime=7810660, deviceId=0, source=0x1002 }
GREEN_Touch action=2, x=23.440296173095703, y=16.704208374023438, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=23.440296, y[0]=16.704208, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=2, eventTime=7810744, downTime=7810660, deviceId=0, source=0x1002 }
RED_Touch action=2, x=23.440296173095703, y=16.704208374023438, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=23.440296, y[0]=16.704208, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=2, eventTime=7810744, downTime=7810660, deviceId=0, source=0x1002 }
GREEN_Touch action=2, x=25.936443328857422, y=21.213516235351563, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=25.936443, y[0]=21.213516, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=2, eventTime=7810761, downTime=7810660, deviceId=0, source=0x1002 }
RED_Touch action=2, x=25.936443328857422, y=21.213516235351563, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=25.936443, y[0]=21.213516, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=2, eventTime=7810761, downTime=7810660, deviceId=0, source=0x1002 }
GREEN_Touch action=2, x=33.13859939575195, y=30.7322998046875, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=33.1386, y[0]=30.7323, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=2, eventTime=7810778, downTime=7810660, deviceId=0, source=0x1002 }
RED_Touch action=2, x=33.13859939575195, y=30.7322998046875, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=33.1386, y[0]=30.7323, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=2, eventTime=7810778, downTime=7810660, deviceId=0, source=0x1002 }
GREEN_Touch action=2, x=42.55187225341797, y=46.21221923828125, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=42.551872, y[0]=46.21222, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=2, eventTime=7810794, downTime=7810660, deviceId=0, source=0x1002 }
RED_Touch action=2, x=42.55187225341797, y=46.21221923828125, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=42.551872, y[0]=46.21222, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=2, eventTime=7810794, downTime=7810660, deviceId=0, source=0x1002 }
GREEN_Touch action=2, x=56.830284118652344, y=66.67816162109375, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=56.830284, y[0]=66.67816, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=2, eventTime=7810811, downTime=7810660, deviceId=0, source=0x1002 }
RED_Touch action=2, x=56.830284118652344, y=66.67816162109375, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=56.830284, y[0]=66.67816, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=2, eventTime=7810811, downTime=7810660, deviceId=0, source=0x1002 }
GREEN_Touch action=2, x=67.34909057617188, y=85.45831298828125, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=67.34909, y[0]=85.45831, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=2, eventTime=7810828, downTime=7810660, deviceId=0, source=0x1002 }
RED_Touch action=2, x=67.34909057617188, y=85.45831298828125, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=67.34909, y[0]=85.45831, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=2, eventTime=7810828, downTime=7810660, deviceId=0, source=0x1002 }
GREEN_Touch action=2, x=75.32483673095703, y=97.9388427734375, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=75.32484, y[0]=97.93884, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=2, eventTime=7810844, downTime=7810660, deviceId=0, source=0x1002 }
RED_Touch action=2, x=75.32483673095703, y=97.9388427734375, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=75.32484, y[0]=97.93884, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=2, eventTime=7810844, downTime=7810660, deviceId=0, source=0x1002 }
GREEN_Touch action=2, x=76.328125, y=101.38983154296875, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=76.328125, y[0]=101.38983, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=2, eventTime=7810861, downTime=7810660, deviceId=0, source=0x1002 }
RED_Touch action=2, x=76.328125, y=101.38983154296875, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=76.328125, y[0]=101.38983, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=2, eventTime=7810861, downTime=7810660, deviceId=0, source=0x1002 }
GREEN_Touch action=2, x=76.328125, y=102.109375, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=76.328125, y[0]=102.109375, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=1, eventTime=7810867, downTime=7810660, deviceId=0, source=0x1002 }
RED_Touch action=2, x=76.328125, y=102.109375, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=106.328125, y[0]=302.10938, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=1, eventTime=7810867, downTime=7810660, deviceId=0, source=0x1002 }
GREEN_Touch action=1, x=76.328125, y=102.109375, ev=MotionEvent { action=ACTION_UP, id[0]=0, x[0]=76.328125, y[0]=102.109375, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=7810943, downTime=7810660, deviceId=0, source=0x1002 }
RED_Touch action=1, x=76.328125, y=102.109375, ev=MotionEvent { action=ACTION_UP, id[0]=0, x[0]=76.328125, y[0]=102.109375, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=7810943, downTime=7810660, deviceId=0, source=0x1002 }

TIA
 

Informatix

Expert
Licensed User
Longtime User
I just discovered The Gesture Detector (v2.4) and it looks incredibly powerful yet simple to use. Congrats on the design. o_O

I am trying to understand one of the demos: GestureDetector_Dispatch. (I am using B4A v7.80 with the emulator)
When I drag within the Red box the Red_onTouch event gets called and returns false to pass control to Activity_Touch, which is fine. I understand that.

This is the log when the red box is dragged and shows the Activity_Touch events as expected:
B4X:
RED_Touch action=0, x=93.1875, y=47.234375, ev=MotionEvent { action=ACTION_DOWN, id[0]=0, x[0]=93.1875, y[0]=47.234375, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=92434, downTime=92434, deviceId=0, source=0x1002 }
ACTIVITY_Touch action=0 (down), x=413.1875, y=347.234375
   ACTIVITY_Touch action=2, x=421.39593505859375, y=369.48968505859375
   ACTIVITY_Touch action=2, x=423.97247314453125, y=376.4143981933594
   ACTIVITY_Touch action=2, x=426.02911376953125, y=380.0436706542969
   ACTIVITY_Touch action=2, x=427.1769104003906, y=381.765380859375
ACTIVITY_Touch action=1 (up), x=427.1769104003906, y=381.765380859375

But when I drag within the green box, GD_Green_OnTouch gets executed and it then calls GD_Red_onTouch using PassTouchEventTo() method. Ok, so far so good. But GD_Red_onTouch still returns false so shouldn't it let Activity_Touch event handle it? But it doesn't. Why not? In other words, why isn't Activity_Touch handling the event after GD_Red_onTouch is called from the GD_Green_onTouch event?

Here are the events that I think should be called: GD_Green_onTouch -> GD_Red_onTouch -> Activity_Touch
But it is only calling: GD_Green_onTouch -> GD_Red_onTouch

A simple drag in the Green box never shows Activity_Touch being called. (Activity_Touch calls are missing)
Remember, GD_Red_onTouch still returns false if called from GD_Green_onTouch event.
B4X:
GREEN_Touch action=0, x=21.15234375, y=12.431640625, ev=MotionEvent { action=ACTION_DOWN, id[0]=0, x[0]=21.152344, y[0]=12.431641, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=7810660, downTime=7810660, deviceId=0, source=0x1002 }
RED_Touch action=0, x=21.15234375, y=12.431640625, ev=MotionEvent { action=ACTION_DOWN, id[0]=0, x[0]=51.152344, y[0]=212.43164, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=7810660, downTime=7810660, deviceId=0, source=0x1002 }
GREEN_Touch action=2, x=23.440296173095703, y=16.704208374023438, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=23.440296, y[0]=16.704208, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=2, eventTime=7810744, downTime=7810660, deviceId=0, source=0x1002 }
RED_Touch action=2, x=23.440296173095703, y=16.704208374023438, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=23.440296, y[0]=16.704208, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=2, eventTime=7810744, downTime=7810660, deviceId=0, source=0x1002 }
GREEN_Touch action=2, x=25.936443328857422, y=21.213516235351563, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=25.936443, y[0]=21.213516, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=2, eventTime=7810761, downTime=7810660, deviceId=0, source=0x1002 }
RED_Touch action=2, x=25.936443328857422, y=21.213516235351563, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=25.936443, y[0]=21.213516, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=2, eventTime=7810761, downTime=7810660, deviceId=0, source=0x1002 }
GREEN_Touch action=2, x=33.13859939575195, y=30.7322998046875, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=33.1386, y[0]=30.7323, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=2, eventTime=7810778, downTime=7810660, deviceId=0, source=0x1002 }
RED_Touch action=2, x=33.13859939575195, y=30.7322998046875, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=33.1386, y[0]=30.7323, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=2, eventTime=7810778, downTime=7810660, deviceId=0, source=0x1002 }
GREEN_Touch action=2, x=42.55187225341797, y=46.21221923828125, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=42.551872, y[0]=46.21222, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=2, eventTime=7810794, downTime=7810660, deviceId=0, source=0x1002 }
RED_Touch action=2, x=42.55187225341797, y=46.21221923828125, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=42.551872, y[0]=46.21222, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=2, eventTime=7810794, downTime=7810660, deviceId=0, source=0x1002 }
GREEN_Touch action=2, x=56.830284118652344, y=66.67816162109375, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=56.830284, y[0]=66.67816, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=2, eventTime=7810811, downTime=7810660, deviceId=0, source=0x1002 }
RED_Touch action=2, x=56.830284118652344, y=66.67816162109375, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=56.830284, y[0]=66.67816, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=2, eventTime=7810811, downTime=7810660, deviceId=0, source=0x1002 }
GREEN_Touch action=2, x=67.34909057617188, y=85.45831298828125, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=67.34909, y[0]=85.45831, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=2, eventTime=7810828, downTime=7810660, deviceId=0, source=0x1002 }
RED_Touch action=2, x=67.34909057617188, y=85.45831298828125, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=67.34909, y[0]=85.45831, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=2, eventTime=7810828, downTime=7810660, deviceId=0, source=0x1002 }
GREEN_Touch action=2, x=75.32483673095703, y=97.9388427734375, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=75.32484, y[0]=97.93884, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=2, eventTime=7810844, downTime=7810660, deviceId=0, source=0x1002 }
RED_Touch action=2, x=75.32483673095703, y=97.9388427734375, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=75.32484, y[0]=97.93884, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=2, eventTime=7810844, downTime=7810660, deviceId=0, source=0x1002 }
GREEN_Touch action=2, x=76.328125, y=101.38983154296875, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=76.328125, y[0]=101.38983, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=2, eventTime=7810861, downTime=7810660, deviceId=0, source=0x1002 }
RED_Touch action=2, x=76.328125, y=101.38983154296875, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=76.328125, y[0]=101.38983, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=2, eventTime=7810861, downTime=7810660, deviceId=0, source=0x1002 }
GREEN_Touch action=2, x=76.328125, y=102.109375, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=76.328125, y[0]=102.109375, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=1, eventTime=7810867, downTime=7810660, deviceId=0, source=0x1002 }
RED_Touch action=2, x=76.328125, y=102.109375, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=106.328125, y[0]=302.10938, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=1, eventTime=7810867, downTime=7810660, deviceId=0, source=0x1002 }
GREEN_Touch action=1, x=76.328125, y=102.109375, ev=MotionEvent { action=ACTION_UP, id[0]=0, x[0]=76.328125, y[0]=102.109375, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=7810943, downTime=7810660, deviceId=0, source=0x1002 }
RED_Touch action=1, x=76.328125, y=102.109375, ev=MotionEvent { action=ACTION_UP, id[0]=0, x[0]=76.328125, y[0]=102.109375, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=7810943, downTime=7810660, deviceId=0, source=0x1002 }

TIA
Are you sure that you did not modify the example provided with the library? I get the right result with it:
GREEN_Touch action=0, x=158, y=183, ev=MotionEvent { action=ACTION_DOWN, actionButton=0, id[0]=0, x[0]=158.0, y[0]=183.0, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=62844112, downTime=62844112, deviceId=9, source=0x1002 }
RED_Touch action=0, x=158, y=183, ev=MotionEvent { action=ACTION_DOWN, actionButton=0, id[0]=0, x[0]=158.0, y[0]=183.0, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=62844112, downTime=62844112, deviceId=9, source=0x1002 }
ACTIVITY_Touch action=0 (down), x=248, y=633
ACTIVITY_Touch action=2, x=251.1284637451172, y=622.6788330078125
ACTIVITY_Touch action=2, x=254.93624877929688, y=615.4183349609375
ACTIVITY_Touch action=2, x=259.896240234375, y=608.8050537109375
ACTIVITY_Touch action=2, x=264.7936096191406, y=603.2752075195312
ACTIVITY_Touch action=2, x=269.1750183105469, y=598.824951171875
ACTIVITY_Touch action=2, x=272.4203186035156, y=595.5796508789062
ACTIVITY_Touch action=2, x=274, y=595
ACTIVITY_Touch action=1 (up), x=274, y=595
...or, more probably, it's an emulator issue.
 

Widget

Well-Known Member
Licensed User
Longtime User
I unzipped the file GestureDetector v2.4.zip again to make sure any of my minor changes (logging) did not affect the code.
I noticed as soon as I drag on the green square, I get 2 errors that I didn't notice before because the log was scrolling too fast.

"Unexpected event (missing RaiseSynchronousEvents): gd_red_ontouch
Check the unfiltered logs for the full stack trace."

If I drag on the green square a 2nd time, no error is produced. The error only shows up the first time I drag on the green square.
Have you seen it?

TIA

B4X:
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
GREEN_Touch action=0, x=26.171875, y=19.4482421875, ev=MotionEvent { action=ACTION_DOWN, id[0]=0, x[0]=26.171875, y[0]=19.448242, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=286231, downTime=286231, deviceId=0, source=0x1002 }
Unexpected event (missing RaiseSynchronousEvents): gd_red_ontouch
Check the unfiltered logs for the full stack trace.
RED_Touch action=0, x=26.171875, y=19.4482421875, ev=MotionEvent { action=ACTION_DOWN, id[0]=0, x[0]=56.171875, y[0]=219.44824, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=286231, downTime=286231, deviceId=0, source=0x1002 }
GREEN_Touch action=2, x=28.610687255859375, y=19.4482421875, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=28.610687, y[0]=19.448242, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=1, eventTime=286244, downTime=286231, deviceId=0, source=0x1002 }
RED_Touch action=2, x=28.610687255859375, y=19.4482421875, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=28.610687, y[0]=19.448242, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=1, eventTime=286244, downTime=286231, deviceId=0, source=0x1002 }
GREEN_Touch action=2, x=31.555240631103516, y=20.814315795898438, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=31.55524, y[0]=20.814316, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=2, eventTime=286261, downTime=286231, deviceId=0, source=0x1002 }
RED_Touch action=2, x=31.555240631103516, y=20.814315795898438, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=31.55524, y[0]=20.814316, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=2, eventTime=286261, downTime=286231, deviceId=0, source=0x1002 }
GREEN_Touch action=2, x=36.549530029296875, y=22.906234741210938, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=36.54953, y[0]=22.906235, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=2, eventTime=286278, downTime=286231, deviceId=0, source=0x1002 }
RED_Touch action=2, x=36.549530029296875, y=22.906234741210938, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=36.54953, y[0]=22.906235, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=2, eventTime=286278, downTime=286231, deviceId=0, source=0x1002 }
GREEN_Touch action=2, x=35.738304138183594, y=23.992889404296875, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=35.738304, y[0]=23.99289, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=1, eventTime=286294, downTime=286231, deviceId=0, source=0x1002 }
RED_Touch action=2, x=35.738304138183594, y=23.992889404296875, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=35.738304, y[0]=23.99289, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=1, eventTime=286294, downTime=286231, deviceId=0, source=0x1002 }
GREEN_Touch action=2, x=37.82295227050781, y=25.073928833007813, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=37.822952, y[0]=25.073929, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=2, eventTime=286311, downTime=286231, deviceId=0, source=0x1002 }
RED_Touch action=2, x=37.82295227050781, y=25.073928833007813, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=37.822952, y[0]=25.073929, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=2, eventTime=286311, downTime=286231, deviceId=0, source=0x1002 }
GREEN_Touch action=2, x=39.04637908935547, y=26.30145263671875, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=39.04638, y[0]=26.301453, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=1, eventTime=286328, downTime=286231, deviceId=0, source=0x1002 }
RED_Touch action=2, x=39.04637908935547, y=26.30145263671875, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=39.04638, y[0]=26.301453, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=1, eventTime=286328, downTime=286231, deviceId=0, source=0x1002 }
GREEN_Touch action=2, x=41.83788299560547, y=29.895492553710938, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=41.837883, y[0]=29.895493, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=2, eventTime=286344, downTime=286231, deviceId=0, source=0x1002 }
RED_Touch action=2, x=41.83788299560547, y=29.895492553710938, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=71.83788, y[0]=229.8955, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=2, eventTime=286344, downTime=286231, deviceId=0, source=0x1002 }
GREEN_Touch action=2, x=45.89464569091797, y=35.13835144042969, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=45.894646, y[0]=35.13835, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=2, eventTime=286361, downTime=286231, deviceId=0, source=0x1002 }
RED_Touch action=2, x=45.89464569091797, y=35.13835144042969, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=45.894646, y[0]=35.13835, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=2, eventTime=286361, downTime=286231, deviceId=0, source=0x1002 }
GREEN_Touch action=2, x=50.21452331542969, y=41.43505859375, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=50.214523, y[0]=41.43506, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=2, eventTime=286378, downTime=286231, deviceId=0, source=0x1002 }
RED_Touch action=2, x=50.21452331542969, y=41.43505859375, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=50.214523, y[0]=41.43506, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=2, eventTime=286378, downTime=286231, deviceId=0, source=0x1002 }
GREEN_Touch action=2, x=52.30438232421875, y=45.55145263671875, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=52.304382, y[0]=45.551453, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=3, eventTime=286394, downTime=286231, deviceId=0, source=0x1002 }
RED_Touch action=2, x=52.30438232421875, y=45.55145263671875, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=52.304382, y[0]=45.551453, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=3, eventTime=286394, downTime=286231, deviceId=0, source=0x1002 }
GREEN_Touch action=2, x=54.36894226074219, y=47.5, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=54.368942, y[0]=47.5, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=2, eventTime=286411, downTime=286231, deviceId=0, source=0x1002 }
RED_Touch action=2, x=54.36894226074219, y=47.5, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=54.368942, y[0]=47.5, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=2, eventTime=286411, downTime=286231, deviceId=0, source=0x1002 }
GREEN_Touch action=2, x=54.2578125, y=48.994140625, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=54.257813, y[0]=48.99414, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=1, eventTime=286422, downTime=286231, deviceId=0, source=0x1002 }
RED_Touch action=2, x=54.2578125, y=48.994140625, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=54.257813, y[0]=48.99414, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=1, eventTime=286422, downTime=286231, deviceId=0, source=0x1002 }
GREEN_Touch action=1, x=54.2578125, y=48.994140625, ev=MotionEvent { action=ACTION_UP, id[0]=0, x[0]=54.257813, y[0]=48.99414, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=286474, downTime=286231, deviceId=0, source=0x1002 }
RED_Touch action=1, x=54.2578125, y=48.994140625, ev=MotionEvent { action=ACTION_UP, id[0]=0, x[0]=84.25781, y[0]=248.99414, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=286474, downTime=286231, deviceId=0, source=0x1002 }
 

Informatix

Expert
Licensed User
Longtime User
I unzipped the file GestureDetector v2.4.zip again to make sure any of my minor changes (logging) did not affect the code.
I noticed as soon as I drag on the green square, I get 2 errors that I didn't notice before because the log was scrolling too fast.

"Unexpected event (missing RaiseSynchronousEvents): gd_red_ontouch
Check the unfiltered logs for the full stack trace."

If I drag on the green square a 2nd time, no error is produced. The error only shows up the first time I drag on the green square.
Have you seen it?

TIA

B4X:
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
GREEN_Touch action=0, x=26.171875, y=19.4482421875, ev=MotionEvent { action=ACTION_DOWN, id[0]=0, x[0]=26.171875, y[0]=19.448242, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=286231, downTime=286231, deviceId=0, source=0x1002 }
Unexpected event (missing RaiseSynchronousEvents): gd_red_ontouch
Check the unfiltered logs for the full stack trace.
RED_Touch action=0, x=26.171875, y=19.4482421875, ev=MotionEvent { action=ACTION_DOWN, id[0]=0, x[0]=56.171875, y[0]=219.44824, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=286231, downTime=286231, deviceId=0, source=0x1002 }
GREEN_Touch action=2, x=28.610687255859375, y=19.4482421875, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=28.610687, y[0]=19.448242, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=1, eventTime=286244, downTime=286231, deviceId=0, source=0x1002 }
RED_Touch action=2, x=28.610687255859375, y=19.4482421875, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=28.610687, y[0]=19.448242, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=1, eventTime=286244, downTime=286231, deviceId=0, source=0x1002 }
GREEN_Touch action=2, x=31.555240631103516, y=20.814315795898438, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=31.55524, y[0]=20.814316, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=2, eventTime=286261, downTime=286231, deviceId=0, source=0x1002 }
RED_Touch action=2, x=31.555240631103516, y=20.814315795898438, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=31.55524, y[0]=20.814316, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=2, eventTime=286261, downTime=286231, deviceId=0, source=0x1002 }
GREEN_Touch action=2, x=36.549530029296875, y=22.906234741210938, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=36.54953, y[0]=22.906235, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=2, eventTime=286278, downTime=286231, deviceId=0, source=0x1002 }
RED_Touch action=2, x=36.549530029296875, y=22.906234741210938, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=36.54953, y[0]=22.906235, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=2, eventTime=286278, downTime=286231, deviceId=0, source=0x1002 }
GREEN_Touch action=2, x=35.738304138183594, y=23.992889404296875, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=35.738304, y[0]=23.99289, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=1, eventTime=286294, downTime=286231, deviceId=0, source=0x1002 }
RED_Touch action=2, x=35.738304138183594, y=23.992889404296875, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=35.738304, y[0]=23.99289, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=1, eventTime=286294, downTime=286231, deviceId=0, source=0x1002 }
GREEN_Touch action=2, x=37.82295227050781, y=25.073928833007813, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=37.822952, y[0]=25.073929, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=2, eventTime=286311, downTime=286231, deviceId=0, source=0x1002 }
RED_Touch action=2, x=37.82295227050781, y=25.073928833007813, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=37.822952, y[0]=25.073929, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=2, eventTime=286311, downTime=286231, deviceId=0, source=0x1002 }
GREEN_Touch action=2, x=39.04637908935547, y=26.30145263671875, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=39.04638, y[0]=26.301453, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=1, eventTime=286328, downTime=286231, deviceId=0, source=0x1002 }
RED_Touch action=2, x=39.04637908935547, y=26.30145263671875, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=39.04638, y[0]=26.301453, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=1, eventTime=286328, downTime=286231, deviceId=0, source=0x1002 }
GREEN_Touch action=2, x=41.83788299560547, y=29.895492553710938, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=41.837883, y[0]=29.895493, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=2, eventTime=286344, downTime=286231, deviceId=0, source=0x1002 }
RED_Touch action=2, x=41.83788299560547, y=29.895492553710938, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=71.83788, y[0]=229.8955, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=2, eventTime=286344, downTime=286231, deviceId=0, source=0x1002 }
GREEN_Touch action=2, x=45.89464569091797, y=35.13835144042969, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=45.894646, y[0]=35.13835, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=2, eventTime=286361, downTime=286231, deviceId=0, source=0x1002 }
RED_Touch action=2, x=45.89464569091797, y=35.13835144042969, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=45.894646, y[0]=35.13835, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=2, eventTime=286361, downTime=286231, deviceId=0, source=0x1002 }
GREEN_Touch action=2, x=50.21452331542969, y=41.43505859375, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=50.214523, y[0]=41.43506, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=2, eventTime=286378, downTime=286231, deviceId=0, source=0x1002 }
RED_Touch action=2, x=50.21452331542969, y=41.43505859375, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=50.214523, y[0]=41.43506, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=2, eventTime=286378, downTime=286231, deviceId=0, source=0x1002 }
GREEN_Touch action=2, x=52.30438232421875, y=45.55145263671875, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=52.304382, y[0]=45.551453, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=3, eventTime=286394, downTime=286231, deviceId=0, source=0x1002 }
RED_Touch action=2, x=52.30438232421875, y=45.55145263671875, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=52.304382, y[0]=45.551453, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=3, eventTime=286394, downTime=286231, deviceId=0, source=0x1002 }
GREEN_Touch action=2, x=54.36894226074219, y=47.5, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=54.368942, y[0]=47.5, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=2, eventTime=286411, downTime=286231, deviceId=0, source=0x1002 }
RED_Touch action=2, x=54.36894226074219, y=47.5, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=54.368942, y[0]=47.5, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=2, eventTime=286411, downTime=286231, deviceId=0, source=0x1002 }
GREEN_Touch action=2, x=54.2578125, y=48.994140625, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=54.257813, y[0]=48.99414, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=1, eventTime=286422, downTime=286231, deviceId=0, source=0x1002 }
RED_Touch action=2, x=54.2578125, y=48.994140625, ev=MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=54.257813, y[0]=48.99414, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=1, eventTime=286422, downTime=286231, deviceId=0, source=0x1002 }
GREEN_Touch action=1, x=54.2578125, y=48.994140625, ev=MotionEvent { action=ACTION_UP, id[0]=0, x[0]=54.257813, y[0]=48.99414, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=286474, downTime=286231, deviceId=0, source=0x1002 }
RED_Touch action=1, x=54.2578125, y=48.994140625, ev=MotionEvent { action=ACTION_UP, id[0]=0, x[0]=84.25781, y[0]=248.99414, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=286474, downTime=286231, deviceId=0, source=0x1002 }
You should not trust the emulator provided by Google. It has serious flaws. Use Genymotion instead or a real device.
 

Widget

Well-Known Member
Licensed User
Longtime User
You should not trust the emulator provided by Google. It has serious flaws. Use Genymotion instead or a real device.

I've never had a problem with the Google emulator when run using Intel hardware acceleration. It's good and fast.
But i took your advice and tried Genymotion (Nexus 7 5.1.0 API 22) this morning and the problem persists. I updated Genymotion to the latest version and retested, and the problem is still there.

Solved It!
Then I decided to try it in Release mode and it worked fine, both with Genymotion and the Android emulator.
That just goes to show you. When everything else fails, try Release mode.:)
 

Informatix

Expert
Licensed User
Longtime User
I've never had a problem with the Google emulator when run using Intel hardware acceleration. It's good and fast.
But i took your advice and tried Genymotion (Nexus 7 5.1.0 API 22) this morning and the problem persists. I updated Genymotion to the latest version and retested, and the problem is still there.

Solved It!
Then I decided to try it in Release mode and it worked fine, both with Genymotion and the Android emulator.
That just goes to show you. When everything else fails, try Release mode.:)
Good news.
I never use the Debug mode, so I forget very often to try my code in Debug mode.
 

zhousongke

Member
Licensed User
Longtime User
This library adds the detection of standard gestures (press, single-tap, double-tap, long tap, drag, scroll, fling, pinch, rotation) to B4A. Instead of using the Touch events to figure out what the user really did, now you just set 15 different listeners with one line of code and you get the gestures as events with all the useful values (scrolling distance, fling velocity, pinch variation, rotation angle...).
With this library, you can also know easily the pressure or the size of a touch event.

It works with any view.

Note: you have to create an instance of GestureDetector (with Dim) for each view you want to bind to the detector with SetOnGestureListener.

v2.2:
- Freeware.

v2.3:
- I fixed an issue with the boolean value returned by the OnTouch event with some views (e.g. ListView or ScrollView);
- I added a new demo (GD_SwipeLV);
- The OnDown event is now raised before OnDoubleTap.

v2.4:
- I fixed an issue when a view is dragged after one of the pointer is up (delta values were computed according to the pointer 0, not to the remaining pointer).

Incompatible with Android versions < 2.


Thanks for your Library "Gesture Detector v2.4" and "ProBundle Free v1.22". But, Dragging OverlayWindow through GestureDetector.OnDrag event is NOT smooth. Is there a good way to solve this problem? Or, like OverlayWindow.Panel.Touch event, use the screen.x/y parameter? The attachment refers to your example.
 

Attachments

  • OverlayWinodw And GestureDetector Test.zip
    12.5 KB · Views: 248

Informatix

Expert
Licensed User
Longtime User
Thanks for your Library "Gesture Detector v2.4" and "ProBundle Free v1.22". But, Dragging OverlayWindow through GestureDetector.OnDrag event is NOT smooth. Is there a good way to solve this problem? Or, like OverlayWindow.Panel.Touch event, use the screen.x/y parameter? The attachment refers to your example.
There is an example of a window moved with the finger provided with the OverlayWindow library: OverlayInfo. You can use it as an inspiration.
I don't understand how to use your attached example. PNL is not over the other apps, so it's impossible to drag it.
And use a real device for your tests, not an emulator like Genymotion.
 

zhousongke

Member
Licensed User
Longtime User
There is an example of a window moved with the finger provided with the OverlayWindow library: OverlayInfo. You can use it as an inspiration.
I don't understand how to use your attached example. PNL is not over the other apps, so it's impossible to drag it.
And use a real device for your tests, not an emulator like Genymotion.


My example tests three ways to drag:


1. Drag the OverlayWindow through the Touch event of the OverlayWindow class . Refer to your example OverlayInfo.b4a .


2. Drag the panel in the activity through the OnDrag event of GestureDetector class . Refer to your example GestureDetector_Drag.b4a .


3. Drag the OverlayWindow through the OnDrag event of GestureDetector class . The reason why I try to use OverlayWindow + GestureDetector is that: in addition to dragging, I also need to perform pinch/fling and other gesture operations on OverlayWindow .

In the third way, the drag is not smooth, using a real device for test. I think the reason may be that the dragging changes the X/Y coordinates of the OverlayWindow, causing the GestureDetector.OnDrag event to get discontinuous X/Y parameters. My suggestion is to add the ScreenX/Y parameter to GestureDetector.OnDrag event, like the OverlayWindow.Touch event .
 

Informatix

Expert
Licensed User
Longtime User
My example tests three ways to drag:


1. Drag the OverlayWindow through the Touch event of the OverlayWindow class . Refer to your example OverlayInfo.b4a .


2. Drag the panel in the activity through the OnDrag event of GestureDetector class . Refer to your example GestureDetector_Drag.b4a .


3. Drag the OverlayWindow through the OnDrag event of GestureDetector class . The reason why I try to use OverlayWindow + GestureDetector is that: in addition to dragging, I also need to perform pinch/fling and other gesture operations on OverlayWindow .

In the third way, the drag is not smooth, using a real device for test. I think the reason may be that the dragging changes the X/Y coordinates of the OverlayWindow, causing the GestureDetector.OnDrag event to get discontinuous X/Y parameters. My suggestion is to add the ScreenX/Y parameter to GestureDetector.OnDrag event, like the OverlayWindow.Touch event .
As I said, your project does not work (click on the Home button of your device and you'll see; PNL is not over the other apps) and I don't have time to fix it. If you just want a floating window, then you should look at my Floating Window class.
 

zhousongke

Member
Licensed User
Longtime User
As I said, your project does not work (click on the Home button of your device and you'll see; PNL is not over the other apps) and I don't have time to fix it. If you just want a floating window, then you should look at my Floating Window class.

Thank you.

My example just tests the difference when gesturedetector is applied to OverlayWindow and panel, instead of putting the panel over the other apps. Hope you can improve the smoothness of dragging the OverlayWindow through the OnDrag event of GestureDetector class .
 

Informatix

Expert
Licensed User
Longtime User
Thank you.

My example just tests the difference when gesturedetector is applied to OverlayWindow and panel, instead of putting the panel over the other apps. Hope you can improve the smoothness of dragging the OverlayWindow through the OnDrag event of GestureDetector class .
I see no problem with this event on the different devices I own. Its code is fairly simple:
B4X:
                    if (ResetStartPos) {
                        StartX = event.getX();
                        StartY = event.getY();
                        ResetStartPos = false;
                    }
                    float deltaX = event.getX() - StartX;
                    float deltaY = event.getY() - StartY;
There's nothing to improve there.
 

Informatix

Expert
Licensed User
Longtime User
Thank you.

My example just tests the difference when gesturedetector is applied to OverlayWindow and panel, instead of putting the panel over the other apps. Hope you can improve the smoothness of dragging the OverlayWindow through the OnDrag event of GestureDetector class .
I retried your project and I saw what you mean. The onDrag event of GD is not suited for an overlay window so use the method shown in OverlayInfo.
Note that onDrag and the other events of GD have nothing in common.
 

Javier Garrido

Member
Licensed User
Can you help me ? How do I capture the end of a longpress?
I want to use an image as an activator of the camera when clicking and when making longpress record video, but I can't capture the final longpress event to finish capturing video.
thanks
 

Informatix

Expert
Licensed User
Longtime User
Can you help me ? How do I capture the end of a longpress?
I want to use an image as an activator of the camera when clicking and when making longpress record video, but I can't capture the final longpress event to finish capturing video.
thanks
As I understand it, you want to detect a long press to start video recording, and after this trigger, detect when the finger lifts to stop the video recording. Is that what you're asking? In this case, you need to use the onLongPress and onPointerUp events.
 

Javier Garrido

Member
Licensed User
As I understand it, you want to detect a long press to start video recording, and after this trigger, detect when the finger lifts to stop the video recording. Is that what you're asking? In this case, you need to use the onLongPress and onPointerUp events.
I want to click take a picture, longclick to start recording video and release the longclick to stop the video recording.
thanks
 

zhousongke

Member
Licensed User
Longtime User
.... The onDrag event of GD is not suited for an overlay window so use the method shown in OverlayInfo....

I modified the code of the OverlayWindow class to raise events such as onTouch, onPointerDown, onPointerUp, onDown, onSingleTapUp, onSingleTapConfirmed, onDoubleTap, onShowPress, onLongPress, onDrag, onScroll, onFling, onPinchOpen, onPinchClose, onRotation
, etc. The ScreenX/Y parameter is added to the onTouch and onDrag events. The library, source code, and samples in the attachment.
 

Attachments

  • OverlayWindowGesture and SourceCode.zip
    33 KB · Views: 279
Top