GestureDetector
GestureDetector
Events:
- onDoubleTap (X As Float, Y As Float, MotionEvent As Object)
- onDown (X As Float, Y As Float, MotionEvent As Object)
- onDrag (deltaX As Float, deltaY As Float, MotionEvent As Object)
- onFling (velocityX As Float, velocityY As Float, MotionEvent1 As Object, MotionEvent2 As Object)
- onLongPress (X As Float, Y As Float, MotionEvent As Object)
- onPinchClose (NewDistance As Float, PreviousDistance As Float, MotionEvent As Object)
- onPinchOpen (NewDistance As Float, PreviousDistance As Float, MotionEvent As Object)
- onPointerDown (ptrIndex As Int, PID As Int, MotionEvent As Object)
- onPointerUp (ptrIndex As Int, PID As Int, MotionEvent As Object)
- onRotation (Degrees As Double, MotionEvent As Object)
- onScroll (distanceX As Float, distanceY As Float, MotionEvent1 As Object, MotionEvent2 As Object)
- onShowPress (X As Float, Y As Float, MotionEvent As Object)
- onSingleTapConfirmed (X As Float, Y As Float, MotionEvent As Object)
- onSingleTapUp (X As Float, Y As Float, MotionEvent As Object)
- onTouch (Action As Int, X As Float, Y As Float, MotionEvent As Object) As Boolean
Fields:
- ACTION_CANCEL As Int
- ACTION_DOWN As Int
- ACTION_MOVE As Int
- ACTION_UP As Int
Functions:
- CreateMotionEvent (downTime As Long, eventTime As Long, Action As Int, X As Float, Y As Float) As Object
Creates a MotionEvent to be used with PassTouchEventTo.
downTime: The time (in ms) when the user originally pressed down to start a stream of position events.
eventTime: The time (in ms) when this specific event was generated.
Action: The kind of action being performed. One of the ACTION constants.
X: The X coordinate of this event.
Y: The Y coordinate of this event.
- EnableLongPress (Enabled As Boolean)
Sets whether longpress is enabled. If this is enabled, when a user presses and holds down, you get a longpress event and nothing further. If it's disabled, the user can press and hold down and then later move their finger and you will get scroll events. By default longpress is enabled.
- getAction (ev As android.view.MotionEvent) As Int
Returns the Action value from the given MotionEvent.
- getHistoricalPressure (ev As android.view.MotionEvent, ptrIndex As Int, pos As Int) As Float
Returns a historical pressure coordinate that occurred between this event and the previous event for the given pointer.
Only applies to ACTION_MOVE events.
- getHistoricalSize (ev As android.view.MotionEvent, ptrIndex As Int, pos As Int) As Float
Returns a historical size coordinate that occurred between this event and the previous event for the given pointer.
Only applies to ACTION_MOVE events.
- getHistoricalX (ev As android.view.MotionEvent, ptrIndex As Int, pos As Int) As Float
Returns a historical X coordinate that occurred between this event and the previous event for the given pointer.
Only applies to ACTION_MOVE events.
- getHistoricalY (ev As android.view.MotionEvent, ptrIndex As Int, pos As Int) As Float
Returns a historical Y coordinate that occurred between this event and the previous event for the given pointer.
Only applies to ACTION_MOVE events.
- getHistorySize (ev As android.view.MotionEvent) As Int
Returns the number of historical points in the given event. These are movements that have occurred between this event and the previous event.
This only applies to ACTION_MOVE events. All other actions will have a size of 0.
- getPID (ev As android.view.MotionEvent, ptrIndex As Int) As Int
Returns the PID for the given pointer index.
0 is the first pointer index.
- getPointerCount (ev As android.view.MotionEvent) As Int
Returns the number of pointers contained in the given event.
- getPointerIndex (ev As android.view.MotionEvent, PID As Int) As Int
Returns the pointer index for the given PID
The PID (Pointer ID) is the pointer unique identifier sent back by the onPointerUp/Down functions.
- getPressure (ev As android.view.MotionEvent, ptrIndex As Int) As Float
Returns the Pressure value from the given MotionEvent.
Set ptrIndex to 0 for the first pointer, to 1 for the second pointer, and so on.
- getSize (ev As android.view.MotionEvent, ptrIndex As Int) As Float
Returns the Size value from the given MotionEvent.
Set ptrIndex to 0 for the first pointer, to 1 for the second pointer, and so on.
- getTouchMajor (ev As android.view.MotionEvent, ptrIndex As Int) As Float
Returns the length of the major axis of an ellipse that describes the touch area at the point of contact for the given pointer index.
minSDK = 9
- getTouchMinor (ev As android.view.MotionEvent, ptrIndex As Int) As Float
Returns the length of the minor axis of an ellipse that describes the touch area at the point of contact for the given pointer index.
minSDK = 9
- getX (ev As android.view.MotionEvent, ptrIndex As Int) As Float
Returns the X value from the given MotionEvent.
Set ptrIndex to 0 for the first pointer, to 1 for the second pointer, and so on.
- getXPrecision (ev As android.view.MotionEvent) As Float
Returns the precision of the X coordinates being reported. You can multiply this number with getX to find the actual hardware value of the X coordinate.
- getY (ev As android.view.MotionEvent, ptrIndex As Int) As Float
Returns the Y value from the given MotionEvent.
Set ptrIndex to 0 for the first pointer, to 1 for the second pointer, and so on.
- getYPrecision (ev As android.view.MotionEvent) As Float
Returns the precision of the Y coordinates being reported. You can multiply this number with getY to find the actual hardware value of the Y coordinate.
- IgnoreHeightForPinch (Ignored As Boolean)
Sets whether the height is ignored when the distance is computed to detect a pinch gesture.
- IgnoreWidthForPinch (Ignored As Boolean)
Sets whether the width is ignored when the distance is computed to detect a pinch gesture.
- PassTouchEventTo (ev As android.view.MotionEvent, Target As android.view.View) As Boolean
Passes the given motion event down to the target view.
Returns True if the event was handled by the view, False otherwise.
- RemoveGestureListener
Removes all gesture listeners for the currently bound view.
- SetOnGestureListener (view As android.view.View, eventPrefix As String)
Sets the listeners for the following events:
onTouch: notified whenever a MotionEvent occurs.
Handler: Sub MyView_onTouch(Action As Int, X As Float, Y As Float, MotionEvent As Object) As Boolean
onPointerDown: notified when a non-primary pointer has gone down.
Handler: Sub MyView_onPointerDown(ptrIndex As Int, PID As Int, MotionEvent As Object)
onPointerUp: notified when a non-primary pointer has gone up.
Handler: Sub MyView_onPointerUp(ptrIndex As Int, PID As Int, MotionEvent As Object)
onDown: notified when a tap occurs with the down MotionEvent that triggered it. This will be triggered immediately for every down event. All other events should be preceded by this.
Handler: Sub MyView_onDown(X As Float, Y As Float, MotionEvent As Object)
onSingleTapUp: notified when a tap occurs with the up MotionEvent that triggered it.
Handler: Sub MyView_onSingleTapUp(X As Float, Y As Float, MotionEvent As Object)
onSingleTapConfirmed: notified when a single-tap occurs. Unlike onSingleTapUp, this will only be called after the detector is confident that the user's first tap is not followed by a second tap leading to a double-tap gesture.
Handler: Sub MyView_onSingleTapConfirmed(X As Float, Y As Float, MotionEvent As Object)
onDoubleTap: notified when a double-tap occurs.
Handler: Sub MyView_onDoubleTap(X As Float, Y As Float, MotionEvent As Object)
onShowPress: the user has performed a down MotionEvent and not performed a move or up yet. This event is commonly used to provide visual feedback to the user to let them know that their action has been recognized i.e. highlight an element.
Handler: Sub MyView_onShowPress(X As Float, Y As Float, MotionEvent As Object)
onLongPress: notified when a long press occurs with the initial on down MotionEvent that triggered it.
Handler: Sub MyView_onLongPress(X As Float, Y As Float, MotionEvent As Object)
onDrag: notified when a drag occurs with the move MotionEvent that triggered it. To move the dragged view, add deltaX to its Left and deltaY to its Top.
Handler: Sub MyView_onDrag(deltaX As Float, deltaY As Float, MotionEvent As Object)
onScroll: notified when a scroll occurs with the initial on down MotionEvent and the current move MotionEvent. The distance in x and y is also supplied.
Handler: Sub MyView_onScroll(distanceX As Float, distanceY As Float, MotionEvent1 As Object, MotionEvent2 As Object)
onFling: notified when a fling occurs with the initial on down MotionEvent and the matching up MotionEvent. The calculated velocity is supplied along the x and y axis in pixels per second.
Handler: Sub MyView_onFling(velocityX As Float, velocityY As Float, MotionEvent1 As Object, MotionEvent2 As Object)
onPinchOpen: notified when the distance increases between two pointers.
Handler: Sub MyView_onPinchOpen(NewDistance As Float, PreviousDistance As Float, MotionEvent As Object)
onPinchClose: notified when the distance decreases between two pointers.
Handler: Sub MyView_onPinchClose(NewDistance As Float, PreviousDistance As Float, MotionEvent As Object)
onRotation: notified when the angle varies between two pointers. The returned angle ranges from -180 to +180 degrees.
Handler: Sub MyView_onRotation(Degrees As Double, MotionEvent As Object)
Author: F. Leneuf-Magaud (Informatix)