GestureEvent Class Reference
| Inherits from | UIEvent : Event |
| Companion guide | |
| Availability | Available in iOS 2.0 and later. |
Overview
The GestureEvent class encapsulates information about a multi-touch gesture.
GestureEvent objects are high-level events that encapsulate the low-level TouchEvent objects. Both GestureEvent and TouchEvent events are sent during a multi-touch sequence. Gesture events contain scaling and rotation information allowing gestures to be combined, if supported by the platform. If not supported, one gesture ends before another starts. Listen for GestureEvent events if you want to respond to gestures only, not process the low-level TouchEvent objects.
The different types of GestureEvent objects that can occur are:
gesturestartSent when two or more fingers touch the surface.
gesturechangeSent when fingers are moved during a gesture.
gestureendSent when the gesture ends (when there are 1 or 0 fingers touching the surface).
For example, for a two finger multi-touch gesture, the events occur in the following sequence:
touchstartfor finger 1. Sent when the first finger touches the surface.gesturestart. Sent when the second finger touches the surface.touchstartfor finger 2. Sent immediately aftergesturestartwhen the second finger touches the surface.gesturechangefor current gesture. Sent when both fingers move while still touching the surface.gestureend. Sent when the second finger lifts from the surface.touchendfor finger 2. Sent immediately aftergestureendwhen the second finger lifts from the surface.touchendfor finger 1. Sent when the first finger lifts from the surface.
See TouchEvent Class Reference if you want to process just low-level TouchEvent objects.
Properties
altKey
A Boolean value indicating whether the alt key is pressed.
readonly attribute boolean altKey
Discussion
If true, the alt key is pressed; otherwise, it is not. If there is no keyboard, this value is false.
Availability
- Available in iOS 2.0 and later.
ctrlKey
A Boolean value indicating whether the control key is pressed.
readonly attribute boolean ctrlKey
Discussion
If true, the control key is pressed; otherwise, it is not. If there is no keyboard, this value is false.
Availability
- Available in iOS 2.0 and later.
metaKey
A Boolean value indicating whether the meta key is pressed.
readonly attribute boolean metaKey
Discussion
If true, the meta key is pressed; otherwise, it is not. If there is no keyboard, this value is false.
Availability
- Available in iOS 2.0 and later.
rotation
The delta rotation since the start of an event, in degrees, where clockwise is positive and counter-clockwise is negative.
readonly attribute float rotation
Discussion
The initial value is 0.0.
Availability
- Available in iOS 2.0 and later.
scale
The distance between two fingers since the start of an event, as a multiplier of the initial distance.
readonly attribute float scale
Discussion
The initial value is 1.0. If less than 1.0, the gesture is pinch close (to zoom out). If greater than 1.0, the gesture is pinch open (to zoom in).
Availability
- Available in iOS 2.0 and later.
shiftKey
A Boolean value indicating whether the shift key is pressed.
readonly attribute boolean shiftKey
Discussion
If true, the Shift key is pressed; otherwise, it is not. If there is no keyboard, this value is false.
Availability
- Available in iOS 2.0 and later.
target
The target of this gesture.
readonly attribute EventTarget target
Availability
- Available in iOS 2.0 and later.
Methods
initGestureEvent
Initializes a newly created GestureEvent object.
Parameters
- type
The type of event that occurred.
- canBubble
Indicates whether an event can bubble. If
true, the event can bubble; otherwise, it cannot.- cancelable
Indicates whether an event can have its default action prevented. If
true, the default action can be prevented; otherwise, it cannot.- view
The view (DOM window) where the event occurred.
- detail
Specifies some detail information about the event depending on the type of event.
- screenX
The x-coordinate of the event’s location in screen coordinates.
- screenY
The y-coordinate of the event’s location in screen coordinates.
- clientX
The x-coordinate of the event’s location relative to the window's viewport.
- clientY
The y-coordinate of the event’s location relative to the window's viewport.
- ctrlKey
If
true, the control key is pressed; otherwise, it is not.- altKey
If
true, the alt key is pressed; otherwise, it is not.- shiftKey
If
true, the Shift key is pressed; otherwise, it is not.- metaKey
If
true, the meta key is pressed; otherwise, it is not.- target
The target of this gesture.
- scale
The distance between two fingers since the start of an event as a multiplier of the initial distance. The initial value is
1.0. If less than1.0, the gesture is pinch close (to zoom out). If greater than1.0, the gesture is pinch open (to zoom in).- rotation
The delta rotation since the start of an event, in degrees, where clockwise is positive and counter-clockwise is negative. The initial value is
0.0.
Discussion
Use this method to programmatically create a GestureEvent object.
Availability
- Available in iOS 2.0 and later.
© 2010 Apple Inc. All Rights Reserved. (Last updated: 2010-12-16)