Q: Gestures Lib, X-Value ?

Mickego

Member
Licensed User
Longtime User
I tried the Gesture Library and Catched
the X-Value when Pressing a ListView.

No Problem getting the Value :)

Problem is that the Gesture Catching
kind of Locks the Press of the item
in my ListView (ids).

My Purpose to catch the xvalue
is to use it in the Function for ids_ItemClick

Sub ids_ItemClick(Position As Int,Value As Object)

I can see the X-Value in a ToastMessage,
but the "ids_ItemClick" is never Fired.

Is it not possible to use it like I want ?
 

Mickego

Member
Licensed User
Longtime User
Sometimes a "LongClick" produces
a "ShortClick" but I can not Use it that way :-(

I have different actions on the ListView
depending on Long or Short Click
 
Upvote 0

Informatix

Expert
Licensed User
Longtime User
Maybe I overlooked something, but with Gestures I can read the X and Y values at "Action Down" and "Action Up" and events are directly passed on to the relevant Object. With GestureDetector I did not succeed to pass short and long press events to the underlying object (especially a Listview). Moving the listview vertically was OK with Gesture Detector and also a horizontal swipe worked (which was one of my wishes). Having to use reflector routines to pass on press events is something I also did not like with Gesture Detector. All my Listview problems have now been solved with Gestures. I can scroll horizontally and vertically and short and long click events also are OK.
Thank you for your feedback.

Here's the declaration of the Down event in GestureDetector:
B4X:
onDown(X As Float, Y As Float, MotionEvent As Object)
...of the SingleTapUp event (you could also use SingleTapUpConfirmed):
B4X:
onSingleTapUp(X As Float, Y As Float, MotionEvent As Object)
...and of the LongPress event:
B4X:
onLongPress(X As Float, Y As Float, MotionEvent As Object)
I can't see where the problem is to get the X and Y coordinates.

I'd like to understand what you mean by "passing events to the object", because Gestures and GestureDetector work the same way (they listen to events; they do not trigger events) and are bound to a specific view (to get its events). Concerning the delegation of events, GestureDetector provides a way to send a MotionEvent to another view as it exports this information; it's impossible with Gestures, which only return basic data.

Even in its first stage, my library never required the Reflection library, so there's maybe a confusion with another library because I don't recognize it here.
 
Upvote 0

Informatix

Expert
Licensed User
Longtime User
Now I am struggling with Gestures and a Webview. Scrolling up and down of a webpage works as well as passing on events except for horizontal scroll which works once but then the listener remains death (events no longer fire).
In Gestures there are a number of strange routines like using an event counter (something to do with "touchscreen noise" (?!)) and strange behaviour depending on whether or not Return True or Return False is used. Also I needed to use CallSubDelayed routine to do webview1.visible = false. Otherwise my App crashes. This is where I am now. If you have some suggestions regarding my webview problem then please let me know. All I want is the webview to act as normal and to use a horizontal swipe to hide the webview (or do something else like Page forward and Page back depending on the swipe direction).
Unfortunately, I never found a use for Webview in my applications so I'm totally incompetent to help you with.
I really wonder whether we talk of the same libraries because there's no "touchscreen noise" property in the Agraham's Gestures library (version 1.2).
 
Upvote 0

Informatix

Expert
Licensed User
Longtime User
Ok I see. Both libraries cannot catch some events because they are intercepted by the view. You can disable this interception by a listview or a scrollview with the following code:
B4X:
    Dim r As Reflector
    r.Target = Your_List
    r.RunMethod2("requestDisallowInterceptTouchEvent", False, "java.lang.boolean")
You have to call this for any touch event with Action = 2 (drag).
Maybe that works also for a WebView.

I looked to the demo of Gestures. Movecount is just there to reduce the number of events to handle. You can safely ignore it. I've heard it was necessary with Android 1.x to limit the number of input events but I have no old device to verify and these early versions have almost disappeared.

About returning True or False: when you get a touchdown event (Action = 0), you have to decide whether your code will process the event and consume it (Return True; the event is not passed to the view).
 
Upvote 0

Informatix

Expert
Licensed User
Longtime User
And I see now what's missing in my library. You cannot return True or False for touch events. And I understand now why you used the reflection library to return this boolean. My library has been designed at the beginning to detect gestures like double tap or fling, which is complicated or impossible to do with the Gestures library.
 
Upvote 0
Top