Skip to content

Commit

Permalink
added a11yClick for NumberControl support, phetsims/scenery#831
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Aug 24, 2018
1 parent 3a2c608 commit 26c5fde
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions js/buttons/RectangularButtonView.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,10 @@ define( function( require ) {
var content = options.content; // convenience variable

// Hook up the input listener
var pressListener = buttonModel.createListener( { tandem: options.tandem.createTandem( 'pressListener' ) } );
this.addInputListener( pressListener );
this.addAccessibleInputListener( pressListener.a11yListener );
// @private (a11y) {PressListener}
this.pressListener = buttonModel.createListener( { tandem: options.tandem.createTandem( 'pressListener' ) } );
this.addInputListener( this.pressListener );
this.addAccessibleInputListener( this.pressListener.a11yListener );

// @private - make the base color into a property so that the appearance strategy can update itself if changes occur.
this.baseColorProperty = new PaintColorProperty( options.baseColor ); // @private
Expand Down Expand Up @@ -177,7 +178,7 @@ define( function( require ) {
buttonAppearanceStrategy.dispose();
contentAppearanceStrategy.dispose();
this.baseColorProperty.dispose();
pressListener.dispose();
this.pressListener.dispose();
interactionStateProperty.unlink( handleInteractionStateChanged );

if ( content ) {
Expand Down Expand Up @@ -545,6 +546,16 @@ define( function( require ) {
getBaseColor: function() { return this.baseColorProperty.value; },
get baseColor() { return this.getBaseColor(); },

/**
* Clicks the button. Recommended only for accessibility usages. For the most part, a11y button functionality should
* be managed by the PressListener.a11yListener. This is more for edge cases.
* @public
* @a11y
*/
a11yClick: function() {
this.pressListener.click();
},

/**
* dispose function
* @public
Expand Down

0 comments on commit 26c5fde

Please sign in to comment.