Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple pick up sounds trigger unexpectedly #1622

Closed
samreid opened this issue Mar 27, 2024 · 1 comment
Closed

Multiple pick up sounds trigger unexpectedly #1622

samreid opened this issue Mar 27, 2024 · 1 comment

Comments

@samreid
Copy link
Member

samreid commented Mar 27, 2024

Discovered in phetsims/faradays-electromagnetic-lab#103, we found that when keyboard dragging an item such as the Projectile Data Lab stopwatch or the Faradays Electromagnetic Lab field meter node, there is a sound when you press an arrow key, indicating the pick up. When you release the key there is a drop sound. That is all working well.

But if you press multiple keys, for instance, to move something at a diagonal, there is an unexpected sound effect. For instance:

  1. Tab to select the Field Meter Node in screen 1 of FEL.
  2. Press the right arrow to start dragging to the right
  3. While dragging to the right, tap the down arrow repeatedly.

The effect is that you will hear multiple pickup sounds even though the tool is already picked up.

Likewise, if you hold down the right arrow and press the left arrow, the object will stop moving and you will hear another "pick up" sound.

I reached out to @jessegreenberg and he said this was unexpected and should be addressed. He indicated the problem may lie in this code:

// If there are no movement keys down, attach a listener to the Pointer that will tell the AnimatedPanZoomListener
// to keep this Node in view
if ( !this.movementKeysDown && KeyboardUtils.isMovementKey( event.domEvent ) ) {
assert && assert( this._pointer === null, 'We should have cleared the Pointer reference by now.' );
this._pointer = event.pointer as PDOMPointer;
event.pointer.addInputListener( this._pointerListener, true );
this.isPressedProperty.value = true;
}
// update the key state
this.keyState.push( {
keyDown: true,
key: key!,
timeDown: 0 // in ms
} );
if ( this._start ) {
if ( this.movementKeysDown ) {
this._start( event );
}
}

This means the "drag started" sequence is getting called more than once, which may be causing other side effects. @jessegreenberg can you please review and advise?

@jessegreenberg
Copy link
Contributor

This was fixed during #1570, the start callback only calls at the start of the operation instead of every key press. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants