Skip to content

Commit

Permalink
move jump alerts to ruler describer, add jumpCenterKeyboardHint, #215
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Jan 1, 2020
1 parent ef89b41 commit 7696b64
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 6 deletions.
7 changes: 5 additions & 2 deletions js/GravityForceLabA11yStrings.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,12 @@ define( require => {
hintPattern: {
value: '{{playHint}} {{releaseHint}}'
},
jumpKeyboardHint: {
grabbedJumpKeyboardHint: {
value: 'Hold J plus C keys to jump ruler to center of m1.'
},
jumpCenterKeyboardHint: {
value: 'Hold J plus H keys to release ruler in home position.'
},
moveKeyboardHint: {
value: 'Move ruler left and right with letter keys A and D.'
},
Expand All @@ -338,7 +341,7 @@ define( require => {
value: 'Centers {{distanceAndUnits}} apart.'
},
jumpCenterMassAlert: {
value: 'Ruler zero mark at center of {{object1}}. {{centersApart}}'
value: 'Ruler zero mark at center of {{object1}}. {{centersApart}} {{supplementalHint}}'
},

// vertical ruler positions
Expand Down
34 changes: 30 additions & 4 deletions js/view/describers/GravityForceLabRulerDescriber.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ define( require => {
const releaseAndExploreHintString = GravityForceLabA11yStrings.releaseAndExploreHint.value;
const hintPatternString = GravityForceLabA11yStrings.hintPattern.value;
const centersApartPatternString = GravityForceLabA11yStrings.centersApartPattern.value;
const jumpKeyboardHintString = GravityForceLabA11yStrings.jumpKeyboardHint.value;
const grabbedJumpKeyboardHintString = GravityForceLabA11yStrings.grabbedJumpKeyboardHint.value;
const jumpCenterKeyboardHintString = GravityForceLabA11yStrings.jumpCenterKeyboardHint.value;
const moveKeyboardHintString = GravityForceLabA11yStrings.moveKeyboardHint.value;
const gestureHintString = GravityForceLabA11yStrings.gestureHint.value;
const keyboardReleaseHintString = GravityForceLabA11yStrings.keyboardReleaseHint.value;
Expand Down Expand Up @@ -80,8 +81,12 @@ define( require => {
this.horizontalDistanceThisGrab = 0; // for horizontal movement alerts
this.previousVerticalRegionIndex = this.getVerticalRegionIndex(); // for vertical movement alerts
this.previousRulerPosition = this.rulerPositionProperty.value;
this.movementUtterance = new Utterance(); // utterance to alert vertical and horizontal movement alerts
this.justMovementAlerted = false;

// @private - alerts for different ruler specific alerts
this.jumpCenterUtterance = new Utterance();
this.jumpHomeUtterance = new Utterance();
this.movementUtterance = new Utterance(); // utterance to alert vertical and horizontal movement alerts
this.releaseAndExploreUtterance = new Utterance( {
alert: releaseAndExploreHintString,
predicate: () => this.releaseAndExploreUtterance.numberOfTimesAlerted < 2 // only alert for the first two time.
Expand Down Expand Up @@ -152,7 +157,7 @@ define( require => {
if ( phet.joist.sim.supportsGestureA11y ) {
return gestureHintString;
}
let playHint = jumpKeyboardHintString;
let playHint = grabbedJumpKeyboardHintString;
const regionIndex = this.getVerticalRegionIndex();

// if on the second grab, the user still isn't in a measurable location, then repeat the first hint to jump to the
Expand Down Expand Up @@ -233,23 +238,44 @@ define( require => {
return currentRegion;
}

/**
* @public
* Alert that the ruler has jumped to the home position
*/
alertJumpHome() {
this.jumpHomeUtterance.alert = this.getHomePositionString();
phet.joist.sim.utteranceQueue.addToBack( this.jumpHomeUtterance );
}

/**
* @public
* @returns {string}
*/
getJumpCenterMassAlert() {
return StringUtils.fillIn( jumpCenterMassAlertString, {
centersApart: this.getCentersApartDistance(),
object1: this.getObjectLabelFromEnum( ISLCObjectEnum.OBJECT_ONE )
object1: this.getObjectLabelFromEnum( ISLCObjectEnum.OBJECT_ONE ),
supplementalHint: this.jumpCenterUtterance.numberOfTimesAlerted < 2 ? jumpCenterKeyboardHintString : ''
} );
}

/**
* @public
* Alert that the ruler has jumped to the center of a mass
*/
alertJumpCenterMass() {
this.jumpCenterUtterance.alert = this.getJumpCenterMassAlert();
phet.joist.sim.utteranceQueue.addToBack( this.jumpCenterUtterance );
}

/**
* @public
*/
reset() {
this.grabbedCount = 0;
this.releaseAndExploreUtterance.reset();
this.jumpCenterUtterance.reset();
this.jumpHomeUtterance.reset();
this.movementUtterance.reset();
}
}
Expand Down

0 comments on commit 7696b64

Please sign in to comment.