Skip to content
Titanium SDK
Version12.6.0

You are reading 12.6.0. See this page in 13.4.1.

Titanium.Gesture

moduleAndroidiPhoneiPadmacOSsince 0.8

Extends Titanium.ModuleTitanium.Proxy

The Gesture module is responsible for high-level device gestures such as orientation changes and shake gestures.

Properties 6

apiName

Stringsince Android 3.2.0, iPhone 3.2.0, iPad 3.2.0, macOS 9.2.0read-only

Inherited from Titanium.Proxy

The name of the API that this proxy corresponds to.

bubbleParent

Booleansince Android 3.0.0, iPhone 3.0.0, iPad 3.0.0, macOS 9.2.0

Inherited from Titanium.Proxy

Indicates if the proxy will bubble an event to its parent.

Default: true

landscape

Booleanread-only

Indicates if the device is currently held in landscape form.

Value is true if in landscape, and false otherwise.

orientation

Numberread-only

Orientation of the device.

Value may be one of the group of Titanium.UI orientation constants, Titanium.UI.PORTRAIT, Titanium.UI.UPSIDE_PORTRAIT, Titanium.UI.LANDSCAPE_LEFT, Titanium.UI.LANDSCAPE_RIGHT, Titanium.UI.FACE_UP, Titanium.UI.FACE_DOWN, or Titanium.UI.UNKNOWN.

On iOS and Windows, returns the current orientation of the device, regardless of the window orientation. To determine the current window orientation, use Window.orientation.

To set the allowable orientations for a window, see Titanium.UI.Window.orientationModes.

portrait

Booleanread-only

Indicates if the device is currently held in portrait form.

Value is true if in portrait, and false otherwise.

Methods 5

Inherited from Titanium.Proxy

Adds the specified callback as an event listener for the named event.

Parameters
ParametersTypeDescription
nameString

Name of the event.

callbackCallback<Titanium.Event>

Callback function to invoke when the event is fired.

4 fields
bubbles Boolean

True if the event will try to bubble up if possible.

cancelBubble Boolean

Set to true to stop the event from bubbling.

source Object

Source object that fired the event.

type String

Name of the event fired.

Inherited from Titanium.Proxy

Fires a synthesized event to any registered listeners.

Parameters
ParametersTypeDescription
nameString

Name of the event.

event?Dictionary

A dictionary of keys and values to add to the Titanium.Event object sent to the listeners.

Inherited from Titanium.Proxy

Removes the specified callback as an event listener for the named event.

Parameters
ParametersTypeDescription
nameString

Name of the event.

callbackCallback<Titanium.Event>

Callback function to remove. Must be the same function passed to addEventListener.

4 fields
bubbles Boolean

True if the event will try to bubble up if possible.

cancelBubble Boolean

Set to true to stop the event from bubbling.

source Object

Source object that fired the event.

type String

Name of the event fired.

stopListener

Androidsince 12.1.0

Stops the gesture listener.

In case you use Titanium.Gesture.landscape or Titanium.Gesture.portrait it will attach the orientation listener automatically. If you just use it once you can use this method to stop the listener.

Events 2

Fired when the device orientation changes.

On Android, note that the application must have a heavyweight window or tab group open in order to receive the orientationchange event. It is not necessary for the heavyweight window to be the topmost window.

Almost all real-world applications will have a heavyweight window or a tab group. This is only likely to be an issue if you create a test case or test application that adds an orientation change listener from app.js without opening a heavyweight window.

Event properties
Event propertiesTypeDescription
orientationNumber

Orientation of the device.

Fired when the device is shaken.

A shake gesture consists of a series of quick accelerations, and is represented by a series of shake events.

The timestamp property represents the interval between shake events. It is measured in milliseconds on Android, and in seconds on iOS.

Event properties
Event propertiesTypeDescription
timestampNumber

Time interval since previous shake event. On iOS, this value is 0 for the first shake event in a series.

xNumber

Acceleration along the X axis, in Gs.

yNumber

Acceleration along the Y axis, in Gs.

zNumber

Acceleration along the Z axis, in Gs.