Skip to content

Commit

Permalink
add getter to Sim.js to access Display.prototype.utteranceQueue, phet…
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Nov 20, 2019
1 parent 954abce commit 600606a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion balloons-and-static-electricity_a11y_view.html
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ <h3>PDOM & Descriptions for Balloons and Static Electricity</h3>
var PDOMCopy = PDOMRoot.cloneNode( true );

// get the alert dom elements from the iframe's inner document
var ariaLiveElementsContainer = innerWindow.phet.joist.sim.display.utteranceQueue.getAriaLiveContainer();
var ariaLiveElementsContainer = innerWindow.phet.joist.sim.utteranceQueue.getAriaLiveContainer();

// get the alert dom elements from the PDOM copy
var alertList = document.getElementById( 'alert-list' );
Expand Down
6 changes: 3 additions & 3 deletions js/balloons-and-static-electricity/view/BalloonNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ define( require => {
if ( self.attemptToMoveBeyondBoundary( event.domEvent.keyCode ) ) {
const attemptedDirection = self.getAttemptedMovementDirection( event.domEvent.keyCode );
boundaryUtterance.alert = self.describer.movementDescriber.getTouchingBoundaryDescription( attemptedDirection );
phet.joist.sim.display.utteranceQueue.addToBack( boundaryUtterance );
phet.joist.sim.utteranceQueue.addToBack( boundaryUtterance );
}
}
} );
Expand Down Expand Up @@ -350,11 +350,11 @@ define( require => {
this.model.setCenter( center );

// clear the queue of utterances that collected as position changed
phet.joist.sim.display.utteranceQueue.clear();
phet.joist.sim.utteranceQueue.clear();

// Send a custom alert, depending on where the balloon was moved to
this.jumpingUtterance.alert = this.describer.movementDescriber.getJumpingDescription( center );
phet.joist.sim.display.utteranceQueue.addToBack( this.jumpingUtterance );
phet.joist.sim.utteranceQueue.addToBack( this.jumpingUtterance );

// reset forces in tracked values in describer that determine description for induced charge change
this.describer.chargeDescriber.resetReferenceForces();
Expand Down
10 changes: 5 additions & 5 deletions js/balloons-and-static-electricity/view/ControlPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ const VBox = require( 'SCENERY/nodes/VBox' );
self.wallButton.innerContent = model.wall.isVisibleProperty.get() ? removeWallString : addWallString;

const alertDescription = wallVisible ? wallAddedString : wallRemovedString;
phet.joist.sim.display.utteranceQueue.addToBack( alertDescription );
phet.joist.sim.utteranceQueue.addToBack( alertDescription );
} );

// Radio buttons related to charges
Expand Down Expand Up @@ -167,7 +167,7 @@ const VBox = require( 'SCENERY/nodes/VBox' );
}

assert && assert( alertString, 'no interactive alert for showChargesProperty value ' + value );
phet.joist.sim.display.utteranceQueue.addToBack( alertString );
phet.joist.sim.utteranceQueue.addToBack( alertString );
} );

// Radio buttons for selecting 1 vs 2 balloons
Expand Down Expand Up @@ -227,17 +227,17 @@ const VBox = require( 'SCENERY/nodes/VBox' );
const resetBalloonButtonListener = function() {

// disable other alerts until after we are finished resetting the balloons
phet.joist.sim.display.utteranceQueue.enabled = false;
phet.joist.sim.utteranceQueue.enabled = false;

model.sweater.reset();
model.balloons.forEach( function( balloon ) {
balloon.reset( true );
} );

phet.joist.sim.display.utteranceQueue.enabled = true;
phet.joist.sim.utteranceQueue.enabled = true;

// alert to assistive technology
phet.joist.sim.display.utteranceQueue.addToBack( StringUtils.fillIn( resetBalloonsAlertPatternString, {
phet.joist.sim.utteranceQueue.addToBack( StringUtils.fillIn( resetBalloonsAlertPatternString, {
balloons: model.greenBalloon.isVisibleProperty.get() ? balloonsString : balloonString
} ) );
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,13 @@ const Vector2 = require( 'DOT/Vector2' );
// the first charge pickup and subsequent pickups (behind a refresh rate) should be announced
if ( self.alertNextPickup || self.alertFirstPickup ) {
alert = self.getChargePickupDescription( self.alertFirstPickup );
phet.joist.sim.display.utteranceQueue.addToBack( alert );
phet.joist.sim.utteranceQueue.addToBack( alert );
}

// announce pickup of last charge, as long as charges are visible
if ( Math.abs( chargeVal ) === BASEConstants.MAX_BALLOON_CHARGE && self.showChargesProperty.get() !== 'none' ) {
alert = self.getLastChargePickupDescription();
phet.joist.sim.display.utteranceQueue.addToBack( alert );
phet.joist.sim.utteranceQueue.addToBack( alert );
}

// reset flags
Expand All @@ -190,15 +190,15 @@ const Vector2 = require( 'DOT/Vector2' );
// when visibility changes, generate the alert and be sure to describe initial movement the next time the
// balloon is released or added to the play area
balloon.isVisibleProperty.lazyLink( function( isVisible ) {
phet.joist.sim.display.utteranceQueue.addToBack( self.getVisibilityChangedDescription() );
phet.joist.sim.utteranceQueue.addToBack( self.getVisibilityChangedDescription() );
self.initialMovementDescribed = false;
self.preventNoMovementAlert = true;
} );

// a11y - if we enter/leave the sweater announce that immediately
balloon.onSweaterProperty.link( function( onSweater ) {
if ( balloon.isDraggedProperty.get() ) {
phet.joist.sim.display.utteranceQueue.addToBack( self.movementDescriber.getOnSweaterString( onSweater ) );
phet.joist.sim.utteranceQueue.addToBack( self.movementDescriber.getOnSweaterString( onSweater ) );
}

// entering sweater, indicate that we need to alert the next charge pickup
Expand All @@ -211,7 +211,7 @@ const Vector2 = require( 'DOT/Vector2' );
if ( !self.balloonModel.jumping ) {
if ( self.describeDirection ) {
self.directionUtterance.alert = self.movementDescriber.getDirectionChangedDescription();
phet.joist.sim.display.utteranceQueue.addToBack( self.directionUtterance );
phet.joist.sim.utteranceQueue.addToBack( self.directionUtterance );
}
}
} );
Expand Down Expand Up @@ -712,21 +712,21 @@ const Vector2 = require( 'DOT/Vector2' );
if ( model.onSweater() || model.touchingWall() ) {

// while dragging, just attractive state and location
phet.joist.sim.display.utteranceQueue.addToBack( this.movementDescriber.getAttractiveStateAndLocationDescriptionWithLabel() );
phet.joist.sim.utteranceQueue.addToBack( this.movementDescriber.getAttractiveStateAndLocationDescriptionWithLabel() );
}
}
else if ( model.onSweater() ) {

// if we stop on the sweater, announce that we are sticking to it
phet.joist.sim.display.utteranceQueue.addToBack( this.movementDescriber.getAttractiveStateAndLocationDescriptionWithLabel() );
phet.joist.sim.utteranceQueue.addToBack( this.movementDescriber.getAttractiveStateAndLocationDescriptionWithLabel() );
}
else {

// if we stop along anywhere else in the play area, describe that movement has stopped
// special case: if the balloon is touching the wall for the first time, don't describe this because
// the section of this function observing that state will describe this
if ( nextTouchingWall === this.describedTouchingWall ) {
phet.joist.sim.display.utteranceQueue.addToBack( this.movementDescriber.getMovementStopsDescription() );
phet.joist.sim.utteranceQueue.addToBack( this.movementDescriber.getMovementStopsDescription() );
}
}
}
Expand Down Expand Up @@ -777,7 +777,7 @@ const Vector2 = require( 'DOT/Vector2' );

// assign an id so that we only announce the most recent alert in the utteranceQueue
this.movementUtterance.alert = utterance;
phet.joist.sim.display.utteranceQueue.addToBack( this.movementUtterance );
phet.joist.sim.utteranceQueue.addToBack( this.movementUtterance );
}

// describe the change in induced charge due to balloon dragging
Expand All @@ -796,7 +796,7 @@ const Vector2 = require( 'DOT/Vector2' );
}

this.inducedChargeChangeUtterance.alert = utterance;
phet.joist.sim.display.utteranceQueue.addToBack( this.inducedChargeChangeUtterance );
phet.joist.sim.utteranceQueue.addToBack( this.inducedChargeChangeUtterance );
}

// update flags that indicate which alerts should come next
Expand All @@ -819,14 +819,14 @@ const Vector2 = require( 'DOT/Vector2' );
if ( !model.jumping ) {
if ( nextTouchingWall ) {
if ( model.isDraggedProperty.get() && this.showChargesProperty.get() === 'all' ) {
phet.joist.sim.display.utteranceQueue.addToBack( this.getWallRubbingDescriptionWithChargePairs() );
phet.joist.sim.utteranceQueue.addToBack( this.getWallRubbingDescriptionWithChargePairs() );
this.describeWallRub = false;
}
else {

// generates a description of how the balloon interacts with the wall
if ( nextVisible ) {
phet.joist.sim.display.utteranceQueue.addToBack( this.movementDescriber.getMovementStopsDescription() );
phet.joist.sim.utteranceQueue.addToBack( this.movementDescriber.getMovementStopsDescription() );
}
}
}
Expand All @@ -839,7 +839,7 @@ const Vector2 = require( 'DOT/Vector2' );

if ( nextIsDragged ) {
utterance = this.movementDescriber.getGrabbedAlert();
phet.joist.sim.display.utteranceQueue.addToBack( utterance );
phet.joist.sim.utteranceQueue.addToBack( utterance );

// we have been picked up successfully, start describing direction
this.describeDirection = true;
Expand Down Expand Up @@ -877,7 +877,7 @@ const Vector2 = require( 'DOT/Vector2' );
if ( !nextVelocity.equals( Vector2.ZERO ) ) {

utterance = this.movementDescriber.getInitialReleaseDescription();
phet.joist.sim.display.utteranceQueue.addToBack( utterance );
phet.joist.sim.utteranceQueue.addToBack( utterance );

// after describing initial movement, continue to describe direction changes
this.describeDirection = true;
Expand All @@ -888,7 +888,7 @@ const Vector2 = require( 'DOT/Vector2' );
// when the balloon is first added to the play area
if ( !this.preventNoMovementAlert ) {
utterance = this.movementDescriber.getNoChangeReleaseDescription();
phet.joist.sim.display.utteranceQueue.addToBack( utterance );
phet.joist.sim.utteranceQueue.addToBack( utterance );
}
this.preventNoMovementAlert = false;
}
Expand All @@ -902,7 +902,7 @@ const Vector2 = require( 'DOT/Vector2' );
// if the balloon is moving slowly, alert a continuous movement description
if ( this.movementDescriber.balloonMovingAtContinousDescriptionVelocity() ) {
utterance = this.movementDescriber.getContinuousReleaseDescription();
phet.joist.sim.display.utteranceQueue.addToBack( utterance );
phet.joist.sim.utteranceQueue.addToBack( utterance );

// reset timer
this.timeSinceReleaseAlert = 0;
Expand All @@ -916,7 +916,7 @@ const Vector2 = require( 'DOT/Vector2' );
if ( this.rubAlertDirty ) {
if ( nextIsDragged && model.onSweater() ) {
this.chargeUtterance.alert = this.getNoChargePickupDescription();
phet.joist.sim.display.utteranceQueue.addToBack( this.chargeUtterance );
phet.joist.sim.utteranceQueue.addToBack( this.chargeUtterance );
}
}
}
Expand Down

0 comments on commit 600606a

Please sign in to comment.