Skip to content

Commit

Permalink
Adding Hotkey.override option, see phetsims/scenery#1621
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanolson committed Apr 4, 2024
1 parent b1eb403 commit 48dd414
Showing 1 changed file with 35 additions and 5 deletions.
40 changes: 35 additions & 5 deletions js/wilder/view/WilderScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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
} )
]
} );
Expand Down

0 comments on commit 48dd414

Please sign in to comment.