Skip to content

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

import { ButtonModel } from 'scenerystack/sun';

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

import type { ButtonModelOptions } from 'scenerystack/sun';

Source Code

See the source for ButtonModel.ts in the sun repository.