diff --git a/js/HomeScreenView.js b/js/HomeScreenView.js index 76a92553..dffaede1 100644 --- a/js/HomeScreenView.js +++ b/js/HomeScreenView.js @@ -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 ) { @@ -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, diff --git a/js/JoistButton.js b/js/JoistButton.js index a2f416e6..5b35ae6c 100644 --- a/js/JoistButton.js +++ b/js/JoistButton.js @@ -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 @@ -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 ); diff --git a/js/KeyboardHelpButton.js b/js/KeyboardHelpButton.js index 23b16498..5c1760b2 100644 --- a/js/KeyboardHelpButton.js +++ b/js/KeyboardHelpButton.js @@ -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' ); @@ -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; diff --git a/js/NavigationBar.js b/js/NavigationBar.js index 7cfdb6d1..2cc22145 100644 --- a/js/NavigationBar.js +++ b/js/NavigationBar.js @@ -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(); + } } } );