I\'m finally switching over fully to JavaFX.
I\'m very keen on keystroke functionality.
Is there an equivalent hotkey architecture to the (very good) one yo
In JavaFX you can register a callback for KeyPressed
events.
For example:
myTextField.setOnKeyPressed(event->{
if (event.getCode() == KeyCode.ENTER){
//do something here
}
}
If you wanted to register a global Key combination (say, the typical Ctrl-S for saving) you could instead use:
myScene.getAccellerators().put(
new KeyCodeCombination(KeyCode.S, KeyCombination.CONTROL_DOWN),
() -> { /** save my work **/ }
)
List of available KeyCodeCombinations: https://docs.oracle.com/javafx/2/api/javafx/scene/input/KeyCodeCombination.html
EDIT(1): how event propagation works
From http://docs.oracle.com/javafx/2/events/processing.htm
The event delivery process contains the following steps: