Constructor
new KeyComposer()
- Source:
Fires:
- event:keyPress
- event:longKeyPress
- event:keyRelease
Example
keyComposer = KeyComposer.createKey(textComponent, "command+z", "undo");
keyComposer.addEventListener("keyPress", undoManager);
// when command+z is pressed inside textComponent,
// undoManager.handleUndoKeyPress() will be called.
Extends
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:
- Inherited From:
- Default Value:
- null
- Source:
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:
- Default Value:
- null
- Source:
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:
- Default Value:
- true
- Source:
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:
- Default Value:
- false
- Source:
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:
- Source:
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:
- Source:
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:
- Source: