Skip to content

Commit

Permalink
convert accessibleClick listener to check on a11yClickProperty, phets…
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Oct 5, 2018
1 parent 9b8ab2c commit f3ba91f
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 19 deletions.
13 changes: 11 additions & 2 deletions js/HomeScreenView.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ define( function( require ) {

var hBox = null;

// @public - for a11y, allow focus to be set when returning to home screen from sim
// @private - for a11y, allow focus to be set when returning to home screen from sim
this.highlightedScreenButton = null;

sim.screenIndexProperty.link( function( screenIndex ) {
Expand Down Expand Up @@ -217,7 +217,16 @@ define( function( require ) {

joist.register( 'HomeScreenView', HomeScreenView );

return inherit( ScreenView, HomeScreenView, {},
return inherit( ScreenView, HomeScreenView, {

/**
* For a11y, highlight the currently selected screen button
* @public
*/
focusHighlightedScreenButton: function() {
this.highlightedScreenButton.focus();
}
},
// @public - statics
{
TITLE_FONT_FAMILY: TITLE_FONT_FAMILY,
Expand Down
12 changes: 4 additions & 8 deletions js/JoistButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,13 @@ define( function( require ) {
highlightExtensionWidth: 0,
highlightExtensionHeight: 0,
highlightCenterOffsetX: 0,
highlightCenterOffsetY: 0,

// a11y
accessibleClick: _.noop // {function} - called at the end of an accessible DOM click by the listener
highlightCenterOffsetY: 0
}, options );

options.tandem = tandem;

// @public (phet-io) - Button model
// Note it shares a tandem with this, so the emitter will be instrumented as a child of the button
// @public (phet-io|a11y) - Button model
// Note it shares a tandem with "this", so the emitter will be instrumented as a child of the button
this.buttonModel = new PushButtonModel( options );

// Create both highlights and only make the one visible that corresponds to the color scheme
Expand Down Expand Up @@ -86,8 +83,7 @@ define( function( require ) {

// Hook up the input listener
var pressListener = this.buttonModel.createListener( {
tandem: tandem.createTandem( 'pressListener' ),
accessibleClick: options.accessibleClick // the PressListener with handle the a11y clicking as well
tandem: tandem.createTandem( 'pressListener' )
} );
this.addInputListener( pressListener );
this.addAccessibleInputListener( pressListener.a11yListener );
Expand Down
14 changes: 8 additions & 6 deletions js/KeyboardHelpButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,7 @@ define( function( require ) {

// a11y
tagName: 'button',
innerContent: hotKeysAndHelpString,
accessibleClick: function() {

// focus the close button if the dialog is open with a keyboard
keyboardHelpDialog.focusCloseButton();
}
innerContent: hotKeysAndHelpString
}, options );

assert && assert( !options.listener, 'KeyboardHelpButton set\'s its own listener' );
Expand All @@ -73,6 +68,13 @@ define( function( require ) {
} );
}
keyboardHelpDialog.show();

// if listener was fired because of accessibility
if ( self.buttonModel.isA11yClicking() ) {

// focus the close button if the dialog is open with a keyboard
keyboardHelpDialog.focusCloseButton();
}
};
options.listener = openDialog;

Expand Down
8 changes: 5 additions & 3 deletions js/NavigationBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,11 @@ define( function( require ) {
tandem.createTandem( 'homeButton' ), {
listener: function() {
sim.showHomeScreenProperty.value = true;
},
accessibleClick: function() {
sim.homeScreen.view.highlightedScreenButton.focus();

// only if fired from a11y
if ( self.homeButton.buttonModel.isA11yClicking() ) {
sim.homeScreen.view.focusHighlightedScreenButton();
}
}
} );

Expand Down

0 comments on commit f3ba91f

Please sign in to comment.