Skip to content
Titanium SDK
Titanium Docs
Version13.4.1

Titanium.UI.Shortcut

proxyAndroidiPhoneiPadmacOSsince Android 9.1.0, iPhone 9.1.0, iPad 9.1.0, macOS 9.2.0

Extends Titanium.Proxy

Manage application shortcuts.

Allows the creation of application shortcuts, which can be detected using the click event from Titanium.UI.Shortcut.

On iOS, shortcuts are only supported on a 3D Touch compatible device. Use the Titanium.UI.iOS.forceTouchSupported property to see if it's supported.

Examples

Simple Shortcut Example

Create a shortcut item and detect its click with the click event.

const win = Ti.UI.createWindow({ backgroundColor: 'grey' });

// Listen for shortcut item clicks from the end-user.
Ti.UI.Shortcut.addEventListener('click', e => {
    // Event's "item" property indicates which shortcut item was clicked on.
    console.log(`id: ${e.item.id}`);

    // Set background to 'blue' when a shortcut was clicked on.
    win.backgroundColor = 'blue';
});

// Button to add a shortcut item.
const btn = Ti.UI.createButton({ title: 'ADD SHORTCUT' });
btn.addEventListener('click', () => {
    const shortcutItem = Ti.UI.createShortcutItem({
        id: 'test_shortcut',
        title: 'TEST',
        description: 'DESCRIPTION'
    });
    Ti.UI.Shortcut.add(shortcutItem);
});
win.add(btn);

win.open();

Properties 5

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

Methods 8

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.

Fetches a shortcut item by its unique string identifier.

Returns a shortcut item with a matching string id. Returns null if a match was not found.

Parameters
ParametersTypeDescription
idString

Identifier of shortcut item to obtain.

Removes all shortcut items from the application.

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.

Events 1