Skip to content

Commit

Permalink
Add radio button sound to field hotkey press - see #284
Browse files Browse the repository at this point in the history
(cherry picked from commit ed44170)
  • Loading branch information
matthew-blackman committed Apr 18, 2024
1 parent d4361e1 commit 3aaeac8
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions js/common-vsm/view/FieldRadioButtonGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -81,6 +82,9 @@ export default class FieldRadioButtonGroup<T extends Field> 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++ ) {
Expand Down

0 comments on commit 3aaeac8

Please sign in to comment.