I have a VBox inside a ScrollPane that contains an HTMLEditor and other things.
When I type text inside HTMLEditor every time I press the spacebar, I get a space inside the editor, as expected, but it also scrolls down Scrollpane. At first I worked on this by adding an EventFilter to the Scrollpane and consuming the KEY_PRESSED event. But now I need this event inside HTMLEditor.
So my question is: is there any flag to tell Scrollpane not to scroll to KeyCode.SPACE, or is there a way to redirect Focus / Key input events only to HTMLEditor, bypassing Scrollpane? Or is there a way to filter this event only on Scrollpane?
You can reproduce this also with javafx Scene Builder:
Scrollpane-> VBox (larger than Scrollpane, so scrollbars will appear) -> 2 * HTMLEditor, Preview in Window, press the spacebar.
Solved: Added EventFilter in HTMLEditor, which consumes KeyCode.SPACE on KEY_PRESSED.
htmlEditor.addEventFilter( KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent event) { if (event.getEventType() == KeyEvent.KEY_PRESSED){
source share