Closed KatieWoe closed 3 months ago
Meeting with @arouinfar and @Nancy-Salpepi:
Constraining the motion to horizontal is the responsibility of the sim; see ResizeHandleKeyboardDragListener and LidHandleKeyboardDragListener. What we need is an option to turn off sound for up/down or left/right arrows, for cases where dragging is constrained to 1 axis.
It looks like @jessegreenberg is out this week, so this may be blocked until 7/8.
I said:
What we need is an option to turn off sound for up/down or left/right arrows, for cases where dragging is constrained to 1 axis.
Looking at SoundDragListener, this does not seem practical. Here's the code that plays the sound when the drag starts:
// @ts-expect-error - The args have implicit any type because of the union of KeyboardDragListenerOptions and
// DragListenerOptions. I (JG) couldn't figure out how to type this properly, even defining the args.
listenerOptions.start = ( ...args ) => {
// @ts-expect-error - see above note.
previousStart && previousStart( ...args );
dragClip!.play();
};
There is currently has no way to check which key has been pressed. Perhaps that could be resolved by figuring out the problem mentioned with args
, and maybe getting key info from those args. But it would add complication.
I'm going to discuss options with @arouinfar.
Summary of discussion with @arouinfar:
So there is nothing to do here, and closing this issue as "won't fix".
Reopening. While investigating a different issue, I discovered this option in KeyboardDragListener. With keyboardDragDirection: 'leftRight'
we get the desired behavior.
// Possible movement types for this KeyboardDragListener. 2D motion ('both') or 1D motion ('leftRight' or 'upDown').
type KeyboardDragDirection = 'both' | 'leftRight' | 'upDown';
...
// Specifies the direction of motion for the KeyboardDragListener. By default, the position Vector2 can change in
// both directions by pressing the arrow keys. But you can constrain dragging to 1D left-right or up-down motion
// with this value.
keyboardDragDirection?: KeyboardDragDirection;
@KatieWoe please review, close if OK. When using the keyboard, the left/right arrows will move the handles and make sound. The up/down arrows will be ignored and will not make sound.
Looks good on main
Test device Samsung Operating System Win 11 Browser Chrome Problem description For https://github.com/phetsims/qa/issues/1100 When using keyboard nav to move the wall of the container or the lid of the container, only left/right will produce movement, but up/down will make sound and disable other items like it should be moving, while no movement happens. Steps to reproduce
Visuals
Troubleshooting information: