# Class: PressComposer

## montage/composer/press-composer~ PressComposer

The `PressComposer` abstracts away handling mouse and touch events that represent presses, allowing generic detection of presses, long presses, and cancelled presses.

## Constructor

#### new PressComposer()

Source:
  - composer/press-composer.js, line 87

##### Fires:

- event:pressStart
- event:press
- event:longPress
- event:pressCancel

### Extends

- Composer

### Members

#### component :Component

The Montage `Component` this `Composer` is attached to. Each composer is attached to a single component. By default, most composer will listen to DOM events on this component's element. This is also the component whose draw cycle is affected by `needsFrame` and `frame`.

##### Type:

- Component

Inherited From:
  - Composer#component
Default Value:
  - null
Source:
  - composer/composer.js, line 39

#### element :Element

The DOM element where the composer will listen for events. If no element is specified then the composer will use the element associated with its `component` property. Subclasses may want to set their `element` to something other than the component's element during `load` for certain event patterns. One common pattern is to set element to `window` to listen for events anywhere on the page.

##### Type:

- Element

Inherited From:
  - Composer#element
Default Value:
  - null
Source:
  - composer/composer.js, line 64

#### lazyLoad

This property controls when the component will call this composer's `load` method, which is where the composer adds its event listeners: - If `false`, the component will call `load` during the next draw cycle after the composer is added to it. - If `true`, the component will call `load` after its `prepareForActivationEvents`. Delaying the creation of event listeners can improve performance.

Inherited From:
  - Composer#lazyLoad
Default Value:
  - true
Source:
  - composer/composer.js, line 99

#### needsFrame :boolean

This property should be set to 'true' when the composer wants to have its `frame()` method executed during the next draw cycle. Setting this property to 'true' will cause Montage to schedule a new draw cycle if one has not already been scheduled.

##### Type:

- boolean

Inherited From:
  - Composer#needsFrame
Default Value:
  - false
Source:
  - composer/composer.js, line 115

### Methods

#### frame(timestamp)

This method will be invoked by the framework at the beginning of a draw cycle. This is where a composer may implement its update logic if it needs to respond to draws by its component.

##### Parameters:

Name | Type | Description
--- | --- | ---
`timestamp` | Date | The time that the draw cycle started

Inherited From:
  - Composer#frame
Source:
  - composer/composer.js, line 137

#### load()

The component calls `load` on its composers when they should initialize themselves. Exactly when this happens is controlled by the composer's `lazyLoad` property. Subclasses should override `load` with their DOM initialization. Most composers attach DOM event listeners to `this.element` in `load`.

Inherited From:
  - Composer#load
Source:
  - composer/composer.js, line 175

#### unload()

The `component` will call `unload` when the composer is removed from the component or the component is removed. Subclasses should override `unload` to do any necessary cleanup, such as removing event listeners.

Inherited From:
  - Composer#unload
Source:
  - composer/composer.js, line 188