phetsims / sun

User-interface components for PhET simulations, built on top of Scenery.
MIT License
4 stars 12 forks source link

Add support for interactive tick marks in Slider. #712

Open pixelzoom opened 3 years ago

pixelzoom commented 3 years ago

Over in https://github.com/phetsims/fourier-making-waves/issues/114#issuecomment-897007348, I added interactive tick labels. Clicking on a tick label sets the Slider's Property to the value associated with that tick. You can find my implementation in FMWNumberControl.js.

A couple of things...

(1) This was harder than it should have been, because Slider addTick sets tick labels to pickable: false. So after calling addTick, I had to work around that by explicitly setting pickable: true for each of my tick labels. I doubt that we're gaining much by making tick labels pickable: false, so I suggest removing that.

(2) @arouinfar found this feature to be very useful, and suggested adding it as an option to Slider. In https://github.com/phetsims/fourier-making-waves/issues/114#issuecomment-897007348:

I would be in favor of adding this feature to Slider. I think it would be helpful in other sims too.

Assigning to @jbphet since he's the responsible dev for this repo. There are a bunch of other Slider-related GitHub issues, and perhaps this should be part of some "epic" that does some much-needed work on Slider.