Skip to content

Commit

Permalink
convert DownUpListener to FireListener, #209
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Nov 22, 2019
1 parent e0af1e4 commit 9fc36a1
Show file tree
Hide file tree
Showing 2 changed files with 203 additions and 4 deletions.
12 changes: 8 additions & 4 deletions js/lab/view/LabProjectilePanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ define( require => {
const ComboBox = require( 'SUN/ComboBox' );
const ComboBoxItem = require( 'SUN/ComboBoxItem' );
const Dimension2 = require( 'DOT/Dimension2' );
const DownUpListener = require( 'SCENERY/input/DownUpListener' );
const FontAwesomeNode = require( 'SUN/FontAwesomeNode' );
const HBox = require( 'SCENERY/nodes/HBox' );
const HStrut = require( 'SCENERY/nodes/HStrut' );
Expand All @@ -25,6 +24,7 @@ define( require => {
const NumberDisplay = require( 'SCENERY_PHET/NumberDisplay' );
const Panel = require( 'SUN/Panel' );
const PhetColorScheme = require( 'SCENERY_PHET/PhetColorScheme' );
const FireListener = require( 'SCENERY/listeners/FireListener' );
const projectileMotion = require( 'PROJECTILE_MOTION/projectileMotion' );
const ProjectileMotionConstants = require( 'PROJECTILE_MOTION/common/ProjectileMotionConstants' );
const RectangularPushButton = require( 'SUN/buttons/RectangularPushButton' );
Expand Down Expand Up @@ -251,10 +251,11 @@ define( require => {
numberMaxWidth: this.textDisplayWidth - 2 * this.options.readoutXMargin
} );

const numberDisplayTandem = tandem.createTandem( 'numberDisplay' );
const numberDisplay = new NumberDisplay(
valueProperty,
range,
merge( valueLabelOptions, { tandem: tandem.createTandem( 'numberDisplay' ), valuePattern: valuePattern } )
merge( valueLabelOptions, { tandem: numberDisplayTandem, valuePattern: valuePattern } )
);

const editValue = () => {
Expand All @@ -277,8 +278,11 @@ define( require => {
tandem: tandem.createTandem( 'editButton' )
} );

numberDisplay.addInputListener( new DownUpListener( { // no removeInputListener required
down: editValue
numberDisplay.addInputListener( new FireListener( { // no removeInputListener required
fire: editValue,
fireOnDown: true,
tandem: numberDisplayTandem.createTandem( 'fireListener' ),
phetioDocumentation: 'When fired, calls listener to open UI to edit the value for this NumberDisplay'
} ) );

const valueNode = new Node( { children: [ numberDisplay, editButton ] } );
Expand Down
195 changes: 195 additions & 0 deletions js/phet-io/projectile-motion-phet-io-elements-baseline.js
Original file line number Diff line number Diff line change
Expand Up @@ -23700,6 +23700,45 @@ window.phet.phetio.phetioElementsBaseline = assert &&
"phetioStudioControl": true,
"phetioTypeName": "NumberDisplayIO"
},
"projectileMotion.labScreen.view.projectilePanel.customControl.altitudeControl.numberDisplay.fireListener.firedEmitter": {
"phetioDocumentation": "A function that executes. No arguments.",
"phetioDynamicElement": false,
"phetioDynamicElementArchetype": false,
"phetioEventType": "USER",
"phetioFeatured": false,
"phetioHighFrequency": false,
"phetioPlayback": false,
"phetioReadOnly": false,
"phetioState": false,
"phetioStudioControl": true,
"phetioTypeName": "EmitterIO<>"
},
"projectileMotion.labScreen.view.projectilePanel.customControl.altitudeControl.numberDisplay.fireListener.pressAction": {
"phetioDocumentation": "Executes whenever a press occurs. The first argument when executing can be used to convey info about the Event. The arguments are:<br/><ol><li>event: EventIO</li></ol>",
"phetioDynamicElement": false,
"phetioDynamicElementArchetype": false,
"phetioEventType": "USER",
"phetioFeatured": false,
"phetioHighFrequency": false,
"phetioPlayback": false,
"phetioReadOnly": false,
"phetioState": false,
"phetioStudioControl": true,
"phetioTypeName": "ActionIO<EventIO>"
},
"projectileMotion.labScreen.view.projectilePanel.customControl.altitudeControl.numberDisplay.fireListener.releaseAction": {
"phetioDocumentation": "Executes whenever a release occurs. The arguments are:<br/><ol><li>event: NullableIO<EventIO></li></ol>",
"phetioDynamicElement": false,
"phetioDynamicElementArchetype": false,
"phetioEventType": "USER",
"phetioFeatured": false,
"phetioHighFrequency": false,
"phetioPlayback": false,
"phetioReadOnly": false,
"phetioState": false,
"phetioStudioControl": true,
"phetioTypeName": "ActionIO<NullableIO<EventIO>>"
},
"projectileMotion.labScreen.view.projectilePanel.customControl.altitudeControl.numberDisplay.opacityProperty": {
"phetioDocumentation": "Opacity of the parent NodeIO, between 0 (invisible) and 1 (fully visible)",
"phetioDynamicElement": false,
Expand Down Expand Up @@ -24038,6 +24077,45 @@ window.phet.phetio.phetioElementsBaseline = assert &&
"phetioStudioControl": true,
"phetioTypeName": "NumberDisplayIO"
},
"projectileMotion.labScreen.view.projectilePanel.customControl.diameterControl.numberDisplay.fireListener.firedEmitter": {
"phetioDocumentation": "A function that executes. No arguments.",
"phetioDynamicElement": false,
"phetioDynamicElementArchetype": false,
"phetioEventType": "USER",
"phetioFeatured": false,
"phetioHighFrequency": false,
"phetioPlayback": false,
"phetioReadOnly": false,
"phetioState": false,
"phetioStudioControl": true,
"phetioTypeName": "EmitterIO<>"
},
"projectileMotion.labScreen.view.projectilePanel.customControl.diameterControl.numberDisplay.fireListener.pressAction": {
"phetioDocumentation": "Executes whenever a press occurs. The first argument when executing can be used to convey info about the Event. The arguments are:<br/><ol><li>event: EventIO</li></ol>",
"phetioDynamicElement": false,
"phetioDynamicElementArchetype": false,
"phetioEventType": "USER",
"phetioFeatured": false,
"phetioHighFrequency": false,
"phetioPlayback": false,
"phetioReadOnly": false,
"phetioState": false,
"phetioStudioControl": true,
"phetioTypeName": "ActionIO<EventIO>"
},
"projectileMotion.labScreen.view.projectilePanel.customControl.diameterControl.numberDisplay.fireListener.releaseAction": {
"phetioDocumentation": "Executes whenever a release occurs. The arguments are:<br/><ol><li>event: NullableIO<EventIO></li></ol>",
"phetioDynamicElement": false,
"phetioDynamicElementArchetype": false,
"phetioEventType": "USER",
"phetioFeatured": false,
"phetioHighFrequency": false,
"phetioPlayback": false,
"phetioReadOnly": false,
"phetioState": false,
"phetioStudioControl": true,
"phetioTypeName": "ActionIO<NullableIO<EventIO>>"
},
"projectileMotion.labScreen.view.projectilePanel.customControl.diameterControl.numberDisplay.opacityProperty": {
"phetioDocumentation": "Opacity of the parent NodeIO, between 0 (invisible) and 1 (fully visible)",
"phetioDynamicElement": false,
Expand Down Expand Up @@ -24376,6 +24454,45 @@ window.phet.phetio.phetioElementsBaseline = assert &&
"phetioStudioControl": true,
"phetioTypeName": "NumberDisplayIO"
},
"projectileMotion.labScreen.view.projectilePanel.customControl.dragCoefficientControl.numberDisplay.fireListener.firedEmitter": {
"phetioDocumentation": "A function that executes. No arguments.",
"phetioDynamicElement": false,
"phetioDynamicElementArchetype": false,
"phetioEventType": "USER",
"phetioFeatured": false,
"phetioHighFrequency": false,
"phetioPlayback": false,
"phetioReadOnly": false,
"phetioState": false,
"phetioStudioControl": true,
"phetioTypeName": "EmitterIO<>"
},
"projectileMotion.labScreen.view.projectilePanel.customControl.dragCoefficientControl.numberDisplay.fireListener.pressAction": {
"phetioDocumentation": "Executes whenever a press occurs. The first argument when executing can be used to convey info about the Event. The arguments are:<br/><ol><li>event: EventIO</li></ol>",
"phetioDynamicElement": false,
"phetioDynamicElementArchetype": false,
"phetioEventType": "USER",
"phetioFeatured": false,
"phetioHighFrequency": false,
"phetioPlayback": false,
"phetioReadOnly": false,
"phetioState": false,
"phetioStudioControl": true,
"phetioTypeName": "ActionIO<EventIO>"
},
"projectileMotion.labScreen.view.projectilePanel.customControl.dragCoefficientControl.numberDisplay.fireListener.releaseAction": {
"phetioDocumentation": "Executes whenever a release occurs. The arguments are:<br/><ol><li>event: NullableIO<EventIO></li></ol>",
"phetioDynamicElement": false,
"phetioDynamicElementArchetype": false,
"phetioEventType": "USER",
"phetioFeatured": false,
"phetioHighFrequency": false,
"phetioPlayback": false,
"phetioReadOnly": false,
"phetioState": false,
"phetioStudioControl": true,
"phetioTypeName": "ActionIO<NullableIO<EventIO>>"
},
"projectileMotion.labScreen.view.projectilePanel.customControl.dragCoefficientControl.numberDisplay.opacityProperty": {
"phetioDocumentation": "Opacity of the parent NodeIO, between 0 (invisible) and 1 (fully visible)",
"phetioDynamicElement": false,
Expand Down Expand Up @@ -24714,6 +24831,45 @@ window.phet.phetio.phetioElementsBaseline = assert &&
"phetioStudioControl": true,
"phetioTypeName": "NumberDisplayIO"
},
"projectileMotion.labScreen.view.projectilePanel.customControl.gravityControl.numberDisplay.fireListener.firedEmitter": {
"phetioDocumentation": "A function that executes. No arguments.",
"phetioDynamicElement": false,
"phetioDynamicElementArchetype": false,
"phetioEventType": "USER",
"phetioFeatured": false,
"phetioHighFrequency": false,
"phetioPlayback": false,
"phetioReadOnly": false,
"phetioState": false,
"phetioStudioControl": true,
"phetioTypeName": "EmitterIO<>"
},
"projectileMotion.labScreen.view.projectilePanel.customControl.gravityControl.numberDisplay.fireListener.pressAction": {
"phetioDocumentation": "Executes whenever a press occurs. The first argument when executing can be used to convey info about the Event. The arguments are:<br/><ol><li>event: EventIO</li></ol>",
"phetioDynamicElement": false,
"phetioDynamicElementArchetype": false,
"phetioEventType": "USER",
"phetioFeatured": false,
"phetioHighFrequency": false,
"phetioPlayback": false,
"phetioReadOnly": false,
"phetioState": false,
"phetioStudioControl": true,
"phetioTypeName": "ActionIO<EventIO>"
},
"projectileMotion.labScreen.view.projectilePanel.customControl.gravityControl.numberDisplay.fireListener.releaseAction": {
"phetioDocumentation": "Executes whenever a release occurs. The arguments are:<br/><ol><li>event: NullableIO<EventIO></li></ol>",
"phetioDynamicElement": false,
"phetioDynamicElementArchetype": false,
"phetioEventType": "USER",
"phetioFeatured": false,
"phetioHighFrequency": false,
"phetioPlayback": false,
"phetioReadOnly": false,
"phetioState": false,
"phetioStudioControl": true,
"phetioTypeName": "ActionIO<NullableIO<EventIO>>"
},
"projectileMotion.labScreen.view.projectilePanel.customControl.gravityControl.numberDisplay.opacityProperty": {
"phetioDocumentation": "Opacity of the parent NodeIO, between 0 (invisible) and 1 (fully visible)",
"phetioDynamicElement": false,
Expand Down Expand Up @@ -25052,6 +25208,45 @@ window.phet.phetio.phetioElementsBaseline = assert &&
"phetioStudioControl": true,
"phetioTypeName": "NumberDisplayIO"
},
"projectileMotion.labScreen.view.projectilePanel.customControl.massControl.numberDisplay.fireListener.firedEmitter": {
"phetioDocumentation": "A function that executes. No arguments.",
"phetioDynamicElement": false,
"phetioDynamicElementArchetype": false,
"phetioEventType": "USER",
"phetioFeatured": false,
"phetioHighFrequency": false,
"phetioPlayback": false,
"phetioReadOnly": false,
"phetioState": false,
"phetioStudioControl": true,
"phetioTypeName": "EmitterIO<>"
},
"projectileMotion.labScreen.view.projectilePanel.customControl.massControl.numberDisplay.fireListener.pressAction": {
"phetioDocumentation": "Executes whenever a press occurs. The first argument when executing can be used to convey info about the Event. The arguments are:<br/><ol><li>event: EventIO</li></ol>",
"phetioDynamicElement": false,
"phetioDynamicElementArchetype": false,
"phetioEventType": "USER",
"phetioFeatured": false,
"phetioHighFrequency": false,
"phetioPlayback": false,
"phetioReadOnly": false,
"phetioState": false,
"phetioStudioControl": true,
"phetioTypeName": "ActionIO<EventIO>"
},
"projectileMotion.labScreen.view.projectilePanel.customControl.massControl.numberDisplay.fireListener.releaseAction": {
"phetioDocumentation": "Executes whenever a release occurs. The arguments are:<br/><ol><li>event: NullableIO<EventIO></li></ol>",
"phetioDynamicElement": false,
"phetioDynamicElementArchetype": false,
"phetioEventType": "USER",
"phetioFeatured": false,
"phetioHighFrequency": false,
"phetioPlayback": false,
"phetioReadOnly": false,
"phetioState": false,
"phetioStudioControl": true,
"phetioTypeName": "ActionIO<NullableIO<EventIO>>"
},
"projectileMotion.labScreen.view.projectilePanel.customControl.massControl.numberDisplay.opacityProperty": {
"phetioDocumentation": "Opacity of the parent NodeIO, between 0 (invisible) and 1 (fully visible)",
"phetioDynamicElement": false,
Expand Down

0 comments on commit 9fc36a1

Please sign in to comment.