From 26c5fde738724f2207ebffb790e6e2c4ace1197c Mon Sep 17 00:00:00 2001 From: zepumph Date: Fri, 24 Aug 2018 12:31:47 -0800 Subject: [PATCH] added a11yClick for NumberControl support, https://github.com/phetsims/scenery/issues/831 --- js/buttons/RectangularButtonView.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/js/buttons/RectangularButtonView.js b/js/buttons/RectangularButtonView.js index 6b2f6e11..3c01a1ed 100644 --- a/js/buttons/RectangularButtonView.js +++ b/js/buttons/RectangularButtonView.js @@ -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 @@ -177,7 +178,7 @@ define( function( require ) { buttonAppearanceStrategy.dispose(); contentAppearanceStrategy.dispose(); this.baseColorProperty.dispose(); - pressListener.dispose(); + this.pressListener.dispose(); interactionStateProperty.unlink( handleInteractionStateChanged ); if ( content ) { @@ -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