Closed pixelzoom closed 1 year ago
Done in the above commit. Tested in the Wave Game screen. Closing.
Looks great! Just FYI, you can remove this now:
checkAnswerButton.pdomDisplayed &&
checkAnswerButton.enabledProperty.value &&
That is now handled by scenery.
@jessegreenberg This listener should only fire when the game is in the state where the user's guess is ready to be checked. How does scenery handle that, or even know about it?
I see now the listener is added to the WaveGameLevelNode. If you want, you can add it to the checkAnswerButton
, and then the global event will only reach the checkAnswerButton
when it is displayed and enabled.
OK thanks - I'll try adding to checkAnswerButton
.
Adding the KeyboardListener to checkAnswerButton
works nicely, and simplifies the logic:
const checkAnswerButtonKeyboardListener = new KeyboardListener( {
keys: [ 'alt+c' ],
callback: ( event, listener ) => checkAnswerListener(),
global: true
} );
@jessegreenberg Note that I also simplified the callback
. Since there is only 1 element in the keys
array, I am not checking listener.keysPressed
in the callback logic. Is this safe, or is it preferrable to check?
Great, thanks! Totally fine to remote that too, the callback will only be called for 'alt+c'.
Excellent. Closing.
From chip away issue https://github.com/phetsims/tasks/issues/1126 ...
In WaveGameLevelNode.ts, replace this with KeyboardListener:
See the example that @jessegreenberg provided in https://github.com/phetsims/tasks/issues/1126#issue-1814396968.