From ed441704b7b05aebe8e8354bcd01dcd887af6df1 Mon Sep 17 00:00:00 2001 From: matthew-blackman Date: Wed, 10 Apr 2024 12:48:05 -0400 Subject: [PATCH] Add radio button sound to field hotkey press - see https://github.com/phetsims/projectile-data-lab/issues/284 --- js/common-vsm/view/FieldRadioButtonGroup.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/js/common-vsm/view/FieldRadioButtonGroup.ts b/js/common-vsm/view/FieldRadioButtonGroup.ts index 231910dc..0d7c868c 100644 --- a/js/common-vsm/view/FieldRadioButtonGroup.ts +++ b/js/common-vsm/view/FieldRadioButtonGroup.ts @@ -16,6 +16,7 @@ import PDLText from '../../common/view/PDLText.js'; import PDLColors from '../../common/PDLColors.js'; import { Circle, KeyboardListener, Rectangle } from '../../../../scenery/js/imports.js'; import Field from '../../common/model/Field.js'; +import multiSelectionSoundPlayerFactory from '../../../../tambo/js/multiSelectionSoundPlayerFactory.js'; type SelfOptions = EmptySelfOptions; type FieldRadioButtonGroupOptions = SelfOptions & RectangularRadioButtonGroupOptions; @@ -81,6 +82,9 @@ export default class FieldRadioButtonGroup extends RectangularR const handleKeypress = ( fieldNumber: number ) => { fieldProperty.value = fields[ fieldNumber - 1 ]; + // Play the sound associated with the selected field + multiSelectionSoundPlayerFactory.getSelectionSoundPlayer( fieldNumber - 1 ).play(); + // Move focus to the radio button that was selected. Without this line, focus would incorrectly remain // on the previous button. Only do this if a radio button already had focus, otherwise it would steal focus for ( let i = 0; i < fieldRadioButtons.length; i++ ) {