PressComposer source
The PressComposer abstracts away handling mouse and touch
events that represent presses, allowing generic detection of presses, long
presses, and cancelled presses.
Specializes Composer
Fires:
- event:pressStart
- event:press
- event:longPress
- event:pressCancel
Properties
-
acceptsActiveTarget :boolean source
-
Whether or not this target can accept user focus and become the activeTarget This matches up with the
document.activeElementproperty purpose-wise; Events from components that should be dispatched as logically occurring at the point of user focus should be dispatched at the activeTargetBy default a target does not accept this responsibility.
Inherited From: Default Value: - false
-
cancelPress source
-
Cancel the current press.
Can be used in a "longPress" event handler to prevent the "press" event being fired.
-
component :Component source
-
The Montage
ComponentthisComposeris 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 byneedsFrameandframe.Inherited From: Default Value: - null
-
delegate :Object source
-
Delegate that implements
surrenderPointer. See Component for explanation of what this method should do.Default Value: - null
-
element :Element source
-
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
componentproperty.Subclasses may want to set their
elementto something other than the component's element duringloadfor certain event patterns. One common pattern is to set element towindowto listen for events anywhere on the page.Inherited From: Default Value: - null
-
isActiveTarget :boolean <readonly> source
-
Whether or not this is the activeTarget
This is a getter and is not bindable. Bind to
defaultEventManager.activeTarget == this.Inherited From: -
lazyLoad source
-
This property controls when the component will call this composer's
loadmethod, which is where the composer adds its event listeners:- If
false, the component will callloadduring the next draw cycle after the composer is added to it. - If
true, the component will callloadafter itsprepareForActivationEvents.
Delaying the creation of event listeners can improve performance.
Inherited From: Default Value: - false
- If
-
longPressThreshold :number source
-
How long a press has to last (in milliseconds) for a longPress event to be dispatched
-
needsFrame :boolean source
-
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.Inherited From: Default Value: - false
-
nextTarget :Component source
-
Which target to distribute an event after this when distributing events throughout a graph of targets.
Inherited From:
Methods
-
didBecomeActiveTarget() source
-
Called after to this target became the activeTarget
Inherited From: -
dispatchEvent(event) source
-
Dispatches the specified event with this target as the event's proximal target
Parameters:
Name Type Description eventEvent The event object to dispatch
Inherited From: -
dispatchEventNamed(type, canBubble, cancelable, detail) source
-
Creates and dispatches an event with the specified properties with this target as the event's proximal target
Parameters:
Name Type Description typestring The type of the event to dispatch
canBubbleboolean Whether or not the event can bubble
cancelableboolean Whether or not the event can be cancelled
detailObject The optional detail object of the event
Inherited From: -
frame(timestamp) source
-
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 timestampDate The time that the draw cycle started
Inherited From: -
removeEventListener(type, listener, useCapture) source
-
Removes an event listener from the object.
Parameters:
Name Type Description typestring The event type.
listenerobject | function The listener object or function.
useCaptureboolean The phase of the event listener.
Inherited From: -
surrendersActiveTarget(newTarget) → {boolean} source
-
Ask this target to surrender its activeTarget status.
Parameters:
Name Type Description newTargetTarget the Target that is about to become the
activeTargetInherited From: Returns: boolean
Whether or not to surrender activeTarget status
-
willBecomeActiveTarget(oldTarget) source
-
Called prior to this target becoming the activeTarget
Parameters:
Name Type Description oldTargetTarget the current activeTarget
Inherited From:
Events
-
longPress
-
Dispatched when a press lasts for longer than (@link longPressThreshold} On a long press, the sequence of events will be: - pressStart: as soon as the composer recognizes it is a press. - longPress:
longPressThresholdafter the pressStart, if the press has not yet ended. - press: when the press ends, if it isn't cancelled.Handlers of the
longPressevent can callcancelPressto preventpressbeing triggered.Parameters:
Name Type Description eventPressEvent -
press
-
Dispatched when a press is complete.
Parameters:
Name Type Description eventPressEvent -
pressCancel
-
Dispatched when a press is canceled. This could be because the pointer left the element, was claimed by another component or maybe a phone call came in.
Parameters:
Name Type Description eventPressEvent -
pressStart
-
Dispatched when a press begins. It is ended by either a press or {@link pressCancel} event.
Parameters:
Name Type Description eventPressEvent
Generated from v0.14.14