Skip to content

Commit

Permalink
convert Utterance(Queue) to typescript, updating typing for Utterance…
Browse files Browse the repository at this point in the history
…, alertDescriptionUtterance, and Voicing speak functions to revolve around IAlertable and ResolvedResponse, phetsims/utterance-queue#67
  • Loading branch information
zepumph committed Mar 12, 2022
1 parent ddb85bc commit e218a68
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions js/Checkbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import Tandem from '../../tandem/js/Tandem.js';
import optionize from '../../phet-core/js/optionize.js';
import sun from './sun.js';
import ISoundPlayer from '../../tambo/js/ISoundPlayer.js';
import { TAlertableDef } from '../../utterance-queue/js/AlertableDef.js';
import Utterance, { IAlertable } from '../../utterance-queue/js/Utterance.js';

// constants
const BOOLEAN_VALIDATOR = { valueType: 'boolean' };
Expand All @@ -47,8 +47,8 @@ type SelfOptions = {
uncheckedSoundPlayer?: ISoundPlayer;

// Utterances to be spoken with a screen reader after the checkbox is pressed. Also used for the voicingContextResponse.
checkedContextResponse?: TAlertableDef | null;
uncheckedContextResponse?: TAlertableDef | null;
checkedContextResponse?: IAlertable;
uncheckedContextResponse?: IAlertable;

// whether a PhET-iO link to the checkbox's Property is created
phetioLinkProperty?: boolean;
Expand Down Expand Up @@ -119,14 +119,12 @@ class Checkbox extends Voicing( Node, 0 ) {
if ( property.value ) {
options.checkedSoundPlayer.play();
options.checkedContextResponse && this.alertDescriptionUtterance( options.checkedContextResponse );
// @ts-ignore TODO https://github.com/phetsims/sun/issues/742
this.voicingSpeakNameResponse( { contextResponse: options.checkedContextResponse } );
this.voicingSpeakNameResponse( { contextResponse: Utterance.alertableToText( options.checkedContextResponse ) } );
}
else {
options.uncheckedSoundPlayer.play();
options.uncheckedContextResponse && this.alertDescriptionUtterance( options.uncheckedContextResponse );
// @ts-ignore TODO https://github.com/phetsims/sun/issues/742
this.voicingSpeakNameResponse( { contextResponse: options.uncheckedContextResponse } );
this.voicingSpeakNameResponse( { contextResponse: Utterance.alertableToText( options.uncheckedContextResponse ) } );
}
}, {
parameters: [],
Expand Down

0 comments on commit e218a68

Please sign in to comment.