-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update hotkeys when list of input listeners changes, see #1621
- Loading branch information
1 parent
92e8bc6
commit b3e6c15
Showing
3 changed files
with
30 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,7 @@ | |
* @author Jonathan Olson <[email protected]> | ||
*/ | ||
|
||
import { EnglishKey, eventCodeToEnglishString, FocusManager, globalHotkeyRegistry, globalKeyStateTracker, Hotkey, KeyboardUtils, metaEnglishKeys, scenery } from '../imports.js'; | ||
import { EnglishKey, eventCodeToEnglishString, FocusManager, globalHotkeyRegistry, globalKeyStateTracker, Hotkey, KeyboardUtils, metaEnglishKeys, Node, scenery } from '../imports.js'; | ||
import DerivedProperty, { UnknownDerivedProperty } from '../../../axon/js/DerivedProperty.js'; | ||
import TProperty from '../../../axon/js/TProperty.js'; | ||
import TinyProperty from '../../../axon/js/TinyProperty.js'; | ||
|
@@ -213,6 +213,22 @@ class HotkeyManager { | |
} ); | ||
} | ||
|
||
/** | ||
* Scenery-internal. If a Node along the focused trail changes its input listeners we need to manually recompute | ||
* the available hotkeys. There is no other way at this time to observe the input listeners of a Node. Otherwise, | ||
* the available hotkeys will be recomputed when focus changes, inputEnabledProperty changes for Nodes along the | ||
* trail, or when global hotkeys change. | ||
* | ||
* Called by Node.addInputListener/Node.removeInputListener. | ||
* | ||
* (scenery-internal) | ||
*/ | ||
public updateHotkeysFromInputListenerChange( node: Node ): void { | ||
if ( FocusManager.pdomFocusProperty.value && FocusManager.pdomFocusProperty.value.trail.nodes.includes( node ) ) { | ||
this.availableHotkeysProperty.recomputeDerivation(); | ||
} | ||
} | ||
|
||
/** | ||
* Given a main `key`, see if there is a hotkey that should be considered "active/pressed" for it. | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters