ButtonModel¶
Overview¶
Base class for button models, which describe the behavior of buttons when users interact with them. Property values are set by an associated listener, see PressListener for details.
@author John Blanco (PhET Interactive Simulations)
Class ButtonModel¶
Constructor¶
new ButtonModel( providedOptions? : ButtonModelOptions )¶
Instance Methods¶
dispose()¶
createPressListener( options? : PressListenerOptions ) : PressListener¶
Creates a PressListener that will handle changes to ButtonModel when the associated button Node is pressed. The client is responsible for adding this PressListener to the associated button Node.
Instance Properties¶
overProperty : Property<boolean>¶
(readonly)
Is the pointer over the button? Value is read-only.
downProperty : Property<boolean>¶
(readonly)
Is the pointer down?
focusedProperty : Property<boolean>¶
(readonly)
Is the button focused from the PDOM?
looksPressedProperty : Property<boolean>¶
(readonly)
This Property was added for a11y. It tracks whether or not the button should "look" down. This will be true if downProperty is true or if an a11y click is in progress. For an a11y click, the listeners are fired right away but the button will look down for as long as PressListener.a11yLooksPressedInterval. See PressListener.click for more details.
looksOverProperty : Property<boolean>¶
(readonly)
This Property was added for a11y. It tracks whether or not the button should "look" over. This will be true if and PressListeners' looksOverProperty is true, see PressListener for that definition.
pdomClickingProperty : Property<boolean>¶
(readonly)
True when the button is being clicked via the PDOM. You can use this Property if custom behavior is needed that is specific to alternative input.
produceSoundEmitter : TEmitter¶
(readonly)
(read-only by users, read-write in subclasses) - emitter that is fired when sound should be produced
interrupted : boolean¶
indicates that interaction was interrupted during a press. Valid until next press.
Type ButtonModelOptions¶
- startCallback?: () => void
called on pointer down - endCallback?: ( over: boolean ) => void
called on pointer up, indicates whether the pointer was released over the button - phetioState?: boolean
to support properly passing this to children, see https://github.com/phetsims/tandem/issues/60 - phetioReadOnly?: boolean
to support properly passing this to children, see https://github.com/phetsims/tandem/issues/60 - phetioFeatured?: boolean
to support properly passing this to children, see https://github.com/phetsims/tandem/issues/60 - & EnabledComponentOptions
Source Code¶
See the source for ButtonModel.ts in the sun repository.