phetsims/scenery-phet

Cannot set enabledProperty of step buttons in TimeControlNode

Closed this issue · 2 comments

Over in phetsims/collision-lab#66, it was decided to disable the step backwards button when the sim is both paused and the elasticity isn't 100%.

Currently, collision-lab uses TimeControlNode for time controls, including the step buttons. However, TimeControlNode doesn't provided any public access to any of its StepButtons. I need access to be able to set the enabledProperty's value to what I need it to be, and I don't think (from quickly looking over the StepButton api) there is an option to do this.

Assigning @jessegreenberg because it looks like he was the main developer of TimeControlNode.

The current way to do this would be to pass an isPlayingProperty option to the TimeControlNode's step button. So your stepBackwardButtonOptions might look like

        stepBackwardButtonOptions: {
          listener: () => stepBackward(),
          isPlayingProperty: new DerivedProperty( [ playProperty, elasticityProperty ], ( playing, elasticity ) => {
            return playing && elasticity < 1;
          } ),
          radius: 20
        },

There is talk of changing this API in phetsims/sun#515 and #563, but that work hasn't been done yet.

Thanks @jessegreenberg. This issue can be closed. I'll keep an eye out for when #563 is addressed.