Skip to content

Commit

Permalink
convert ComboBoxItem from class to type, phetsims/sun#768
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelzoom committed Jun 27, 2022
1 parent 59ef625 commit dfe69b2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
11 changes: 5 additions & 6 deletions js/demo/testing/view/RemoveAndDisposeSoundGeneratorsTestPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ import StringUtils from '../../../../../phetcommon/js/util/StringUtils.js';
import PhetFont from '../../../../../scenery-phet/js/PhetFont.js';
import { HBox, Node, Text, VBox } from '../../../../../scenery/js/imports.js';
import TextPushButton from '../../../../../sun/js/buttons/TextPushButton.js';
import ComboBox from '../../../../../sun/js/ComboBox.js';
import ComboBoxItem from '../../../../../sun/js/ComboBoxItem.js';
import ComboBox, { ComboBoxItem } from '../../../../../sun/js/ComboBox.js';
import Panel, { PanelOptions } from '../../../../../sun/js/Panel.js';
import birdCall_mp3 from '../../../../sounds/demo-and-test/birdCall_mp3.js';
import cricketsLoop_mp3 from '../../../../sounds/demo-and-test/cricketsLoop_mp3.js';
Expand Down Expand Up @@ -89,10 +88,10 @@ class RemoveAndDisposeSoundGeneratorsTestPanel extends Panel {
// Create the combo box for selecting the type of sound generator to add.
const comboBoxItems: ComboBoxItem<string>[] = [];
SOUND_GENERATOR_INFO.forEach( ( soundGenerator, soundGeneratorKey ) => {
comboBoxItems.push( new ComboBoxItem(
new Text( soundGenerator.comboBoxItemName, { font: COMBO_BOX_FONT } ),
soundGeneratorKey
) );
comboBoxItems.push( {
value: soundGeneratorKey,
node: new Text( soundGenerator.comboBoxItemName, { font: COMBO_BOX_FONT } )
} );
} );
const selectedSoundGeneratorTypeProperty = new Property( comboBoxItems[ 0 ].value );
const comboBox = new ComboBox( selectedSoundGeneratorTypeProperty, comboBoxItems, panelContentNode, {
Expand Down
7 changes: 3 additions & 4 deletions js/demo/ui-components/view/UIComponentsScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import BooleanRectangularToggleButton from '../../../../../sun/js/buttons/Boolea
import RectangularPushButton from '../../../../../sun/js/buttons/RectangularPushButton.js';
import Checkbox from '../../../../../sun/js/Checkbox.js';
import ComboBox from '../../../../../sun/js/ComboBox.js';
import ComboBoxItem from '../../../../../sun/js/ComboBoxItem.js';
import DemosScreenView from '../../../../../sun/js/demo/DemosScreenView.js';
import accordion_png from '../../../../images/accordion_png.js';
import tambo from '../../../tambo.js';
Expand Down Expand Up @@ -166,9 +165,9 @@ class UIComponentsScreenView extends DemosScreenView {
{
label: 'ComboBox',
createNode: ( layoutBounds: Bounds2 ) => new ComboBox( new NumberProperty( 0 ), [
new ComboBoxItem( new Text( 'Rainbows', { font: LABEL_FONT } ), 0 ),
new ComboBoxItem( new Text( 'Unicorns', { font: LABEL_FONT } ), 1 ),
new ComboBoxItem( new Text( 'Butterflies', { font: LABEL_FONT } ), 2 )
{ value: 0, node: new Text( 'Rainbows', { font: LABEL_FONT } ) },
{ value: 1, node: new Text( 'Unicorns', { font: LABEL_FONT } ) },
{ value: 2, node: new Text( 'Butterflies', { font: LABEL_FONT } ) }
], this, { center: layoutBounds.center } )
},
{
Expand Down

0 comments on commit dfe69b2

Please sign in to comment.