Is it possible to limit the input length in a JavaFX HTMLEditor? I tried to add an event handler to the editor and consume the event when the content reaches a predefined limit but it doesn't seem to work.
editor.addEventHandler(KeyEvent.KEY_TYPED, new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent arg0) {
if (editor.getHtmlText().length() >= MY_LIMIT) {
arg0.consume();
}
}
});
Did anybody manage to achieve this? Is it even possible?
Thanks in advance.