Skip to content

Commit

Permalink
move displayOnlyProperty to ComboBox, #451
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelzoom committed Jan 21, 2019
1 parent 4dbb961 commit 7c73852
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 13 deletions.
13 changes: 13 additions & 0 deletions js/ComboBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,19 @@ define( require => {
};
this.enabledProperty.link( enabledObserver );

// @private for use via PhET-iO, see https://github.com/phetsims/sun/issues/451
// This is NOT reset when the Reset All button is pressed.
this.displayOnlyProperty = new BooleanProperty( false, {
tandem: options.tandem.createTandem( 'displayOnlyProperty' ),
phetioDocumentation: 'disables interaction with the ComboBox and ' +
'makes it appear like a display that shows the current selection'
} );
this.displayOnlyProperty.link( displayOnly => {
this.hideListBox();
this.button.setDisplayOnly( displayOnly );
this.pickable = !displayOnly;
} );

// @private called by dispose
this.disposeComboBox = () => {

Expand Down
27 changes: 14 additions & 13 deletions js/ComboBoxButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ define( require => {

// modules
const AccessiblePeer = require( 'SCENERY/accessibility/AccessiblePeer' );
const BooleanProperty = require( 'AXON/BooleanProperty' );
const HStrut = require( 'SCENERY/nodes/HStrut' );
const Node = require( 'SCENERY/nodes/Node' );
const Path = require( 'SCENERY/nodes/Path' );
Expand Down Expand Up @@ -188,18 +187,20 @@ define( require => {
property.unlink( propertyObserver );
};

// @private for use via PhET-iO, see https://github.com/phetsims/sun/issues/451
// This is NOT reset when the Reset All button is pressed.
this.displayOnlyProperty = new BooleanProperty( false, {
tandem: options.tandem.createTandem( 'displayOnlyProperty' ),
phetioDocumentation: 'disables interaction with the ComboBox button and ' +
'makes it appear like a display that shows the current selection'
} );
this.displayOnlyProperty.link( displayOnly => {
arrow.visible = !displayOnly;
separator.visible = !displayOnly;
this.pickable = !displayOnly;
} );
// @private needed by methods
this.arrow = arrow;
this.separator = separator;
}

/**
* Sets the button to look like a value display instead of a combo box button.
* See https://github.com/phetsims/sun/issues/451
* @param {boolean} displayOnly
* @public
*/
setDisplayOnly( displayOnly ) {
this.arrow.visible = !displayOnly;
this.separator.visible = !displayOnly;
}

/**
Expand Down

0 comments on commit 7c73852

Please sign in to comment.