Skip to content

Commit

Permalink
apply phetioFeatured customizations to ComboBox, #587
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Apr 15, 2020
1 parent 52d63db commit d74441a
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 5 deletions.
8 changes: 7 additions & 1 deletion js/ComboBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import PDOMPeer from '../../scenery/js/accessibility/pdom/PDOMPeer.js';
import Display from '../../scenery/js/display/Display.js';
import Node from '../../scenery/js/nodes/Node.js';
import EventType from '../../tandem/js/EventType.js';
import PhetioObject from '../../tandem/js/PhetioObject.js';
import Tandem from '../../tandem/js/Tandem.js';
import ComboBoxButton from './ComboBoxButton.js';
import ComboBoxIO from './ComboBoxIO.js';
Expand Down Expand Up @@ -92,6 +93,9 @@ class ComboBox extends Node {
phetioEventType: EventType.USER
}, options );

// Use this pattern so that passed in phetioComponentOptions are not blown away.
PhetioObject.mergePhetioComponentOptions( { visibleProperty: { phetioFeatured: true } }, options );

// validate option values
assert && assert( options.xMargin > 0 && options.yMargin > 0,
'margins must be > 0, xMargin=' + options.xMargin + ', yMargin=' + options.yMargin );
Expand Down Expand Up @@ -216,7 +220,8 @@ class ComboBox extends Node {

// @public Provide a default if not specified
this.enabledProperty = options.enabledProperty || new BooleanProperty( true, {
tandem: options.tandem.createTandem( 'enabledProperty' )
tandem: options.tandem.createTandem( 'enabledProperty' ),
phetioFeatured: true
} );

// enable/disable the combo box
Expand All @@ -232,6 +237,7 @@ class ComboBox extends Node {
// This is not generally controlled by the user, so it is not reset when the Reset All button is pressed.
this.displayOnlyProperty = new BooleanProperty( false, {
tandem: options.tandem.createTandem( 'displayOnlyProperty' ),
phetioFeatured: true,
phetioDocumentation: 'disables interaction with the ComboBox and ' +
'makes it appear like a display that shows the current selection'
} );
Expand Down
9 changes: 9 additions & 0 deletions js/ComboBoxButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import PDOMPeer from '../../scenery/js/accessibility/pdom/PDOMPeer.js';
import HStrut from '../../scenery/js/nodes/HStrut.js';
import Node from '../../scenery/js/nodes/Node.js';
import Path from '../../scenery/js/nodes/Path.js';
import PhetioObject from '../../tandem/js/PhetioObject.js';
import Tandem from '../../tandem/js/Tandem.js';
import RectangularButtonView from './buttons/RectangularButtonView.js';
import RectangularPushButton from './buttons/RectangularPushButton.js';
Expand Down Expand Up @@ -47,6 +48,11 @@ class ComboBoxButton extends RectangularPushButton {
stroke: 'black',
lineWidth: 1,

// PushButtonModel options
enabledPropertyOptions: {
phetioFeatured: false
},

// phet-io
tandem: Tandem.OPTIONAL,

Expand All @@ -62,6 +68,9 @@ class ComboBoxButton extends RectangularPushButton {
assert && assert( _.includes( ARROW_DIRECTION_VALUES, options.arrowDirection ),
'invalid arrowDirection: ' + options.arrowDirection );

// Use this pattern so that passed in phetioComponentOptions are not blown away.
PhetioObject.mergePhetioComponentOptions( { visibleProperty: { phetioFeatured: true } }, options );

// To improve readability
const itemXMargin = options.xMargin;

Expand Down
5 changes: 5 additions & 0 deletions js/ComboBoxListBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import KeyboardUtils from '../../scenery/js/accessibility/KeyboardUtils.js';
import SceneryEvent from '../../scenery/js/input/SceneryEvent.js';
import VBox from '../../scenery/js/nodes/VBox.js';
import EventType from '../../tandem/js/EventType.js';
import PhetioObject from '../../tandem/js/PhetioObject.js';
import Tandem from '../../tandem/js/Tandem.js';
import ComboBoxListItemNode from './ComboBoxListItemNode.js';
import Panel from './Panel.js';
Expand Down Expand Up @@ -51,6 +52,10 @@ class ComboBoxListBox extends Panel {
tandem: tandem
}, options );

// Use this pattern so that passed in phetioComponentOptions are not blown away.
// list box visibility is controlled by the combo box, and should not be controlled through the PhET-iO API.
PhetioObject.mergePhetioComponentOptions( { visibleProperty: { phetioReadOnly: true } }, options );

assert && assert( options.xMargin > 0 && options.yMargin > 0,
'margins must be > 0, xMargin=' + options.xMargin + ', yMargin=' + options.yMargin );

Expand Down
5 changes: 4 additions & 1 deletion js/ComboBoxListItemNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import Shape from '../../kite/js/Shape.js';
import merge from '../../phet-core/js/merge.js';
import Node from '../../scenery/js/nodes/Node.js';
import Rectangle from '../../scenery/js/nodes/Rectangle.js';
import PhetioObject from '../../tandem/js/PhetioObject.js';
import Tandem from '../../tandem/js/Tandem.js';
import ComboBoxItem from './ComboBoxItem.js';
import sun from './sun.js';
Expand Down Expand Up @@ -43,9 +44,11 @@ class ComboBoxListItemNode extends Node {
tagName: 'li',
focusable: true,
ariaRole: 'option'

}, options );

// Use this pattern so that passed in phetioComponentOptions are not blown away.
PhetioObject.mergePhetioComponentOptions( { visibleProperty: { phetioFeatured: true } }, options );

// pdom: get innerContent from the item
assert && assert( options.innerContent === undefined, 'ComboBoxListItemNode sets innerContent' );
options.innerContent = item.a11yLabel;
Expand Down
5 changes: 2 additions & 3 deletions js/buttons/RectangularButtonView.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,8 @@ function RectangularButtonView( buttonModel, interactionStateProperty, options )
accessibleClick: options.accessibleClick
}, options.listenerOptions );

PhetioObject.mergePhetioComponentOptions( {
visibleProperty: { phetioFeatured: true }
}, options );
// Use this pattern so that passed in phetioComponentOptions are not blown away.
PhetioObject.mergePhetioComponentOptions( { visibleProperty: { phetioFeatured: true } }, options );

this.buttonModel = buttonModel; // @protected

Expand Down

0 comments on commit d74441a

Please sign in to comment.