diff --git a/js/common/view/TickMarkViewRadioButtonGroup.ts b/js/common/view/TickMarkViewRadioButtonGroup.ts index 0198af03..b9fc4f74 100644 --- a/js/common/view/TickMarkViewRadioButtonGroup.ts +++ b/js/common/view/TickMarkViewRadioButtonGroup.ts @@ -7,7 +7,7 @@ */ import merge from '../../../../phet-core/js/merge.js'; -import { ParallelDOM, Path, PathOptions } from '../../../../scenery/js/imports.js'; +import { ParallelDOM, Path, PathOptions, voicingUtteranceQueue } from '../../../../scenery/js/imports.js'; import eyeSlashSolidShape from '../../../../sherpa/js/fontawesome-5/eyeSlashSolidShape.js'; import RectangularRadioButtonGroup from '../../../../sun/js/buttons/RectangularRadioButtonGroup.js'; import ActivationUtterance from '../../../../utterance-queue/js/ActivationUtterance.js'; @@ -16,6 +16,7 @@ import ratioAndProportionStrings from '../../ratioAndProportionStrings.js'; import TickMarkView from './TickMarkView.js'; import EnumerationProperty from '../../../../axon/js/EnumerationProperty.js'; import optionize from '../../../../phet-core/js/optionize.js'; +import ResponsePacket from '../../../../utterance-queue/js/ResponsePacket.js'; // constants const ICON_SCALE = 0.45; @@ -40,42 +41,62 @@ class TickMarkViewRadioButtonGroup extends RectangularRadioButtonGroup { - - switch( tickMarkView ) { - case TickMarkView.NONE: - tickMarkContextResponseUtterance.alert = ratioAndProportionStrings.a11y.tickMark.tickMarksHidden; - break; - case TickMarkView.VISIBLE: - tickMarkContextResponseUtterance.alert = ratioAndProportionStrings.a11y.tickMark.tickMarksShown; - break; - - case TickMarkView.VISIBLE_WITH_UNITS: - tickMarkContextResponseUtterance.alert = ratioAndProportionStrings.a11y.tickMark.numberedTickMarksShown; - break; - default: - assert && assert( false, 'unsupported tickMarkView' ); - } + const voicingResponsePacket = new ResponsePacket(); + const tickMarkVoicingContextResponseUtterance = new ActivationUtterance( { + alert: voicingResponsePacket + } ); + tickMarkViewProperty.lazyLink( tickMarkView => { + // TODO: likely we need this to run on user input, not the model Property, https://github.com/phetsims/ratio-and-proportion/issues/363 + + const currentRadioButtonItem = _.find( radioButtonItemData, item => item.value === tickMarkView )!; + assert && assert( currentRadioButtonItem, 'radio button item expected' ); + + voicingResponsePacket.nameResponse = currentRadioButtonItem.labelContent; + voicingResponsePacket.contextResponse = currentRadioButtonItem.voicingContextResponse; + voicingUtteranceQueue.addToBack( tickMarkVoicingContextResponseUtterance ); + // interactive description alert + tickMarkContextResponseUtterance.alert = currentRadioButtonItem.interactiveDescriptionContextResponse; this.alertDescriptionUtterance( tickMarkContextResponseUtterance ); } ); }