# Titanium.UI.Shortcut

> Manage application shortcuts.

- Source: https://titaniumsdk.com/docs/sdk/13.0.0/Titanium.UI.Shortcut
- Titanium SDK version: 13.0.0
- Kind: proxy
- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK Android 9.1.0, iPhone 9.1.0, iPad 9.1.0, macOS 9.2.0
- Extends: Titanium.Proxy
- Inheritance: Titanium.Proxy

Allows the creation of application shortcuts, which can be detected using
the `click` event from [Titanium.UI.Shortcut](https://titaniumsdk.com/docs/sdk/Titanium.UI.Shortcut.md).

On iOS, shortcuts are only supported on a 3D Touch compatible device.
Use the [Titanium.UI.iOS.forceTouchSupported](https://titaniumsdk.com/docs/sdk/Titanium.UI.iOS.md#forceTouchSupported) property to see if it's supported.

## Example: Simple Shortcut Example

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

``` javascript
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

### items

- Type: Array<Titanium.UI.ShortcutItem>
- Platforms: Android, iPhone, iPad, macOS
- Permission: read-only

List dynamic shortcuts.

Array of shortcut items that were added to the app via the [Titanium.UI.Shortcut.add](https://titaniumsdk.com/docs/sdk/Titanium.UI.Shortcut.md#add) method.

### staticItems

- Type: Array<Titanium.UI.ShortcutItem>
- Platforms: Android, iPhone, iPad, macOS
- Permission: read-only

List current pinned/static shortcuts.

## Methods

### add

- Platforms: Android, iPhone, iPad, macOS

Adds a shortcut item to the application.

Parameters:

- `item` (Titanium.UI.ShortcutItem): [Titanium.UI.ShortcutItem](https://titaniumsdk.com/docs/sdk/Titanium.UI.ShortcutItem.md) to add.

### getById

- Platforms: Android, iPhone, iPad, macOS

Fetches a shortcut item by its unique string identifier.

Returns a shortcut item with a matching string [id](https://titaniumsdk.com/docs/sdk/Titanium.UI.ShortcutItem.md#id).
Returns `null` if a match was not found.

Parameters:

- `id` (String): Identifier of shortcut item to obtain.

Returns: Titanium.UI.ShortcutItem

### remove

- Platforms: Android, iPhone, iPad, macOS

Removes the given shortcut item from the application.

Parameters:

- `item` (Titanium.UI.ShortcutItem): [Titanium.UI.ShortcutItem](https://titaniumsdk.com/docs/sdk/Titanium.UI.ShortcutItem.md) to remove.

### removeAll

- Platforms: Android, iPhone, iPad, macOS

Removes all shortcut items from the application.

## Events

### click

- Platforms: Android, iPhone, iPad, macOS

Fired when a [Titanium.UI.ShortcutItem](https://titaniumsdk.com/docs/sdk/Titanium.UI.ShortcutItem.md) was clicked on.

Event properties:

- `item` (Titanium.UI.ShortcutItem): The shortcut item clicked.

## Inherited members

7 members are inherited. Each is documented on the type that declares it.

- [Titanium.Proxy](https://titaniumsdk.com/docs/sdk/13.0.0/Titanium.Proxy.md): `addEventListener`, `apiName`, `applyProperties`, `bubbleParent`, `fireEvent`, `lifecycleContainer`, `removeEventListener`

---

- This corpus documents Titanium SDK 13.4.1. Anything here that does not name a version describes 13.4.1.
- Titanium is maintained by TiDev. The Appcelerator toolchain is retired: there is no `appc` CLI, no Appcelerator Studio and no hosted build service. The supported CLI is `titanium` on npm, invoked as `ti`.

