Skip to content

ResetAllButton

ResetAllButton (from scenerystack/scenery-phet) is the standard orange circular button that appears in the bottom-right of every PhET-style ScreenView and restores that screen's model and view to their initial state. It's a specialized ResetButton (itself a RoundPushButton) that additionally handles PhET-iO state restoration, interrupting in-progress input, and voicing/alert suppression while the reset is in progress.

ts
import { ResetAllButton } from 'scenerystack/scenery-phet';

A minimal example

ts
class MyScreenView extends ScreenView {
  public constructor( model: MyModel, tandem: Tandem ) {
    super( { tandem } );

    const resetAllButton = new ResetAllButton( {
      listener: () => {
        model.reset();
        this.reset();
      },
      right: this.layoutBounds.maxX - 25,
      bottom: this.layoutBounds.maxY - 25,
      tandem: tandem.createTandem( 'resetAllButton' )
    } );
    this.addChild( resetAllButton );
  }
}

Options

ResetAllButtonOptions is SelfOptions & ResetButtonOptions (minus xMargin/yMargin, which ResetAllButton fixes itself). The listener option is inherited all the way from RoundPushButton — call your model's (and view's) reset() from it.

OptionDefaultEffect
listenerCallback fired when the button is pressed; this is where you call model.reset()
radiusSceneryPhetConstants.DEFAULT_BUTTON_RADIUSButton radius
phetioRestoreScreenStateOnResettrueIn a PhET-iO build, also restores the screen to its last-saved PhET-iO state
interruptScreenViewInputtrueInterrupts any in-progress input (drags, etc.) on ancestor ScreenViews before resetting
baseColorPhetColorScheme.RESET_ALL_BUTTON_BASE_COLORThe standard PhET orange
touchAreaDilation5.2Tuned touch-area expansion — avoid overriding lightly

Built-in behavior

  • Fires an alt+R global keyboard hotkey (ResetAllButton.RESET_ALL_HOTKEY_DATA) equivalent to pressing the button.
  • Mutes voicing/description alerts while the reset is firing, then announces a single "everything was reset" alert afterward instead of a flood of per-Property alerts.

Requires a real tandem

Like most PhET-iO-instrumented components, tandem defaults to Tandem.REQUIRED with tandemNameSuffix: 'ResetAllButton'. Supply a real child tandem (e.g. screenTandem.createTandem( 'resetAllButton' )) — see Tandem — rather than leaving the sentinel default in place.