Skip to content

Commit

Permalink
First pass at voicing for my challenge accordion box, #381
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Apr 26, 2021
1 parent 6a83969 commit 25c797c
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 10 deletions.
13 changes: 13 additions & 0 deletions js/common/view/describers/RatioDescriber.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,19 @@ class RatioDescriber {
} );
}

/**
* @public
* @param {number} antecedent
* @param {number} consequent
* @returns {string}
*/
getMyChallengeSentence( antecedent, consequent ) {
return StringUtils.fillIn( ratioAndProportionStrings.a11y.ratio.myChallenge, {
targetAntecedent: antecedent,
targetConsequent: consequent
} );
}

/**
* @public
* @param {number} antecedent
Expand Down
29 changes: 26 additions & 3 deletions js/create/view/MyChallengeAccordionBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,20 @@ class MyChallengeAccordionBox extends AccordionBox {
mouseAreaYDilation: 5
},

// voicing
// TODO: this doesn't work because a sub component of the AccordionBox gets focus instead of the A-box itself. https://github.com/phetsims/ratio-and-proportion/issues/381
voicingCreateObjectResponse: event => {
if ( event.type === 'focus' ) {
return ratioAndProportionStrings.myChallenge;
}
},
voicingCreateHintResponse: event => {
if ( event.type === 'focus' ) {
return ratioAndProportionStrings.a11y.create.myChallengeHintText;
}
},


// phet-io
tandem: Tandem.REQUIRED
}, options );
Expand Down Expand Up @@ -151,11 +165,20 @@ class MyChallengeAccordionBox extends AccordionBox {
this.expandedProperty.value = DEFAULT_EXPANDED;

const accordionBoxUtterance = new ActivationUtterance();
const accordionBoxVoicingUtterance = new ActivationUtterance();
this.expandedProperty.lazyLink( expanded => {
accordionBoxUtterance.alert = expanded ?
ratioDescriber.getCurrentChallengeSentence( targetAntecedentProperty.value, targetConsequentProperty.value ) :
ratioAndProportionStrings.a11y.ratio.currentChallengeHidden;

if ( expanded ) {
accordionBoxUtterance.alert = ratioDescriber.getCurrentChallengeSentence( targetAntecedentProperty.value, targetConsequentProperty.value );
accordionBoxVoicingUtterance.alert = ratioDescriber.getMyChallengeSentence( targetAntecedentProperty.value, targetConsequentProperty.value );
}
else {
accordionBoxUtterance.alert = ratioAndProportionStrings.a11y.ratio.currentChallengeHidden;
accordionBoxVoicingUtterance.alert = ratioAndProportionStrings.a11y.ratio.myChallengeHidden;
}

phet.joist.sim.utteranceQueue.addToBack( accordionBoxUtterance );
phet.joist.sim.voicingUtteranceQueue && phet.joist.sim.voicingUtteranceQueue.addToBack( accordionBoxVoicingUtterance );
} );

Property.multilink( [ targetAntecedentProperty, targetConsequentProperty ], ( targetAntecedent, targetConsequent ) => {
Expand Down
17 changes: 10 additions & 7 deletions js/ratio-and-proportion-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @author Michael Kauzmann (PhET Interactive Simulations)
*/

// import PreferencesConfiguration from '../../joist/js/preferences/PreferencesConfiguration.js';
import PreferencesConfiguration from '../../joist/js/preferences/PreferencesConfiguration.js';
import Sim from '../../joist/js/Sim.js';
import simLauncher from '../../joist/js/simLauncher.js';
import Tandem from '../../tandem/js/Tandem.js';
Expand All @@ -24,12 +24,15 @@ const simOptions = {
qualityAssurance: 'Logan Bray, Steele Dalton, Megan Lai, Brooklyn Lash, Liam Mulhall, Devon Quispe, Kathryn Woessner',
soundDesign: 'Ashton Morris'
},
hasKeyboardHelpContent: true
// preferencesConfiguration: new PreferencesConfiguration( {
// audioOptions: {
// supportsVoicing: true
// }
// } )
hasKeyboardHelpContent: true,
preferencesConfiguration: new PreferencesConfiguration( {
audioOptions: {
supportsVoicing: true
},
visualOptions: {
supportsInteractiveHighlights: true
}
} )
};

// launch the sim - beware that scenery Image nodes created outside of simLauncher.launch() will have zero bounds
Expand Down
9 changes: 9 additions & 0 deletions ratio-and-proportion-strings_en.json
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,9 @@
"myChallengeHelpText": {
"value": "Set left and right values to create your challenge, then move hands to explore it."
},
"myChallengeHintText": {
"value": "Expand to set your challenge."
},
"bothHandsGestureDescriptionHelpText": {
"value": "Explore challenge ratio with individual Left and Right hands, or try with ratio locked. The custom Both Hands interaction is not yet possible with screen reader software on a mobile device."
}
Expand Down Expand Up @@ -525,6 +528,12 @@
"currentChallengeHidden": {
"value": "Current challenge hidden."
},
"myChallenge": {
"value": "My challenge {{targetAntecedent}} to {{targetConsequent}}."
},
"myChallengeHidden": {
"value": "My challenge hidden."
},
"capitalized": {
"at": {
"value": "At"
Expand Down

0 comments on commit 25c797c

Please sign in to comment.