From 48dd4148f2491a01ed98544a6bde00ee06a921f2 Mon Sep 17 00:00:00 2001 From: Jonathan Olson Date: Thu, 4 Apr 2024 15:19:32 -0600 Subject: [PATCH] Adding Hotkey.override option, see https://github.com/phetsims/scenery/issues/1621 --- js/wilder/view/WilderScreenView.ts | 40 ++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/js/wilder/view/WilderScreenView.ts b/js/wilder/view/WilderScreenView.ts index 8c989b3..1e59ffe 100644 --- a/js/wilder/view/WilderScreenView.ts +++ b/js/wilder/view/WilderScreenView.ts @@ -120,12 +120,38 @@ class WilderScreenView extends ScreenView { } ) } ) ); + this.addInputListener( { + hotkeys: [ + new Hotkey( { + key: 'x', + fire: () => console.log( 'fire: x (screen view)' ) + } ), + new Hotkey( { + key: 'w', + fire: () => console.log( 'fire: w (screen view)' ) + } ), + new Hotkey( { + key: 'a', + fire: () => console.log( 'fire: a (screen view)' ) + } ), + new Hotkey( { + key: 's', + fire: () => console.log( 'fire: s (screen view)' ) + } ), + new Hotkey( { + key: 'd', + fire: () => console.log( 'fire: d (screen view)' ) + } ) + ] + } ); + resetAllButton.addInputListener( { hotkeys: [ new Hotkey( { key: 'x', fire: () => console.log( 'fire: x' ), - enabledProperty: extraEnabledProperty + enabledProperty: extraEnabledProperty, + override: true } ), new Hotkey( { key: 'x', @@ -135,19 +161,23 @@ class WilderScreenView extends ScreenView { } ), new Hotkey( { key: 'w', - fire: () => console.log( 'fire: w' ) + fire: () => console.log( 'fire: w' ), + override: true } ), new Hotkey( { key: 'a', - fire: () => console.log( 'fire: a' ) + fire: () => console.log( 'fire: a' ), + override: true } ), new Hotkey( { key: 's', - fire: () => console.log( 'fire: s' ) + fire: () => console.log( 'fire: s' ), + override: true } ), new Hotkey( { key: 'd', - fire: () => console.log( 'fire: d' ) + fire: () => console.log( 'fire: d' ), + override: true } ) ] } );