Skip to content

Commit

Permalink
use PressListener for a11y click, see phetsims/scenery#831
Browse files Browse the repository at this point in the history
  • Loading branch information
jessegreenberg committed Aug 24, 2018
1 parent ccaeddf commit 82fd0e0
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 23 deletions.
5 changes: 1 addition & 4 deletions js/buttons/RectangularPushButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ define( function( require ) {

options = _.extend( {
tandem: Tandem.required,
phetioType: PushButtonIO,

// a11y - listener that will only be called when using the keyboard to interact with the push button
accessibleFire: function() {}
phetioType: PushButtonIO
}, options );

// If a listener was passed in, save it and add it after creating the button model. This is done so that
Expand Down
1 change: 1 addition & 0 deletions js/buttons/RoundButtonView.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ define( function( require ) {
// @private {PressListener}
var pressListener = pushButtonModel.createListener( { tandem: options.tandem.createTandem( 'pressListener' ) } );
this.addInputListener( pressListener );
this.addAccessibleInputListener( pressListener.a11yListener );

// Use the user-specified radius if present, otherwise calculate the
// radius based on the content and the margin.
Expand Down
20 changes: 1 addition & 19 deletions js/buttons/RoundPushButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ define( function( require ) {
phetioType: PushButtonIO,

// a11y
tagName: 'button',
accessibleFire: function() {}
tagName: 'button'
}, options );

var self = this;
Expand All @@ -53,24 +52,7 @@ define( function( require ) {
// add the listener that was potentially saved above
listener && this.addListener( listener );

// a11y - when the button is clicked with assistive technology, fire
var clickListener = {
click: function() {
if ( self.enabled ) {
self.buttonModel.a11yClick( options.accessibleFire );
}
},
focus: function() {
self.buttonModel.overProperty.value = true;
},
blur: function() {
self.buttonModel.a11yBlur();
}
};
this.addAccessibleInputListener( clickListener );

this.disposeRoundPushButton = function() {
self.removeAccessibleInputListener( clickListener );
self.buttonModel.dispose();
};
}
Expand Down

0 comments on commit 82fd0e0

Please sign in to comment.