PushButtonModel¶
Overview¶
Basic model for a push button, including over/down/enabled properties.
@author Sam Reid (PhET Interactive Simulations) @author John Blanco (PhET Interactive Simulations) @author Chris Malley (PixelZoom, Inc.)
Class PushButtonModel¶
Constructor¶
new PushButtonModel( providedOptions? : PushButtonModelOptions )¶
Instance Methods¶
dispose()¶
addListener( listener : PushButtonListener )¶
Adds a listener. If already a listener, this is a no-op. @param listener - function called when the button is pressed, no args
removeListener( listener : PushButtonListener )¶
Removes a listener. If not a listener, this is a no-op.
fire()¶
Fires all listeners. Public for phet-io and a11y use.
Instance Properties¶
isFiringProperty : Property<boolean>¶
(readonly)
used by ResetAllButton to call functions during reset start/end
Type PushButtonListener¶
() => void
Type PushButtonModelOptions¶
- fireOnDown?: boolean
true: fire on pointer down; false: fire on pointer up if pointer is over button - listener?: PushButtonListener | null
convenience for adding 1 listener, no args - interruptListener?: ( ( event: SceneryEvent | null ) => void ) | null
a listener that gets fired before other listeners on this button, with the express purpose of just interrupting other input/pointers for better multi-touch support. See https://github.com/phetsims/sun/issues/858 - fireOnHold?: boolean
fire-on-hold feature TODO: these options are not supported with PDOM interaction, see https://github.com/phetsims/scenery/issues/1117 - fireOnHoldDelay?: number
- fireOnHoldInterval?: number
- phetioReadOnly?: boolean
to support properly passing this to children, see https://github.com/phetsims/tandem/issues/60 - & ButtonModelOptions
Source Code¶
See the source for PushButtonModel.ts in the sun repository.