Closed Nancy-Salpepi closed 2 years ago
Wow, good catch @Nancy-Salpepi. I guess there's yet-another thing special/different that has to be done for keyboard navigtion + Slider.
Notes to self:
In DiscreteScreenView, the Amplitudes chart is instantiated with option onEdit
which switches the Waveform to 'custom' when any amplitude is changed by the user:
const amplitudesChartNode = new DiscreteAmplitudesChartNode( model.amplitudesChart, amplitudeKeypadDialog, {
// Changing any amplitude switches the waveform to 'custom'.
onEdit: () => { model.waveformProperty.value = Waveform.CUSTOM; },
tandem: amplitudesTandem.createTandem( 'amplitudesChartNode' )
} );
In InteractiveAmplitudesChartNode (the superclass of DiscreteAmplitudesChartNode) onEdit
is passed to the Slider and NumberDisplay with the press
option:
const sliders = fourierSeries.harmonics.map( harmonic =>
new AmplitudeSlider( harmonic, emphasizedHarmonics, merge( {
press: options.onEdit,
...
const numberDisplays = fourierSeries.harmonics.map( harmonic =>
new AmplitudeNumberDisplay( harmonic, emphasizedHarmonics, amplitudeKeypadDialog, merge( {
press: options.onEdit,
In AmplitudeSlider, press
is passed to a PressListener. There is something similair in AmplitudeNumberDisplay.
this.addInputListener( new PressListener( {
attach: false,
press: options.press
} ) );
So it looks like keyboard input does not result in firing of PressListeners. Is that expected behavior @jessegreenberg ? If so... What doesn't PressListener handle keyboard input? And what do I need to add to duplicate this behavior for keyboard input.
This is what I would expect, this is very similar to https://github.com/phetsims/fourier-making-waves/issues/87. PressListener does support activation with alternative input, but not arrow key presses like this.
Instead of a PressListener would it be possible to use the startDrag
option of Slider.js? That will be called from all forms of supported input.
PressListener does support activation with alternative input, but not arrow key presses like this.
@jessegreenberg If I want to listen for arrow key presses, what should I use? I'm surprised that there's nothing like "KeyboardListener".
Fix pushed to master and 1.0 branches. I used @jessegreenberg's suggestion -- I replaced PressListener
with option startDrag
. That was complicated by the fact that I have a custom track and thumb. It would have been much more straightforward to add something like "KeyboardListener", but no such thing seems to exist.
@Nancy-Salpepi would you please give this a test in master? Then assign back to me.
Looks good on Master using MacBook (11.6) + chrome/safari and iMac (10.15.7) + chrome.
Thanks @Nancy-Salpepi.
Ready for testing in the next RC. To verify:
This works as it should following the steps in https://github.com/phetsims/fourier-making-waves/issues/200#issuecomment-933714636
Test device iMac
Operating System 10.15.7
Browser chrome
Problem description https://github.com/phetsims/qa/issues/711
In the Discrete Screen, when using keyboard nav, the waveform type doesn't switch to custom when any of the amplitude sliders are manipulated.
Steps to reproduce
Visuals