In JavaFX, when I create an HTMLEditor, it appears at first with the buttons greyed out, like so
Only after I click in the editing area does the editor come to life (buttons no longer disabled) and the cursor appears
I want the editor to load without becoming disabled, and be ready for editing right away without having to click on the edit area first. I.e. cursor ready to enter text, buttons not disabled.
I've tried some different things:
htmlEditor.requestFocus();
does nothing. Also I tried simulating a click in the WebEngine, which also had no effect:
// for manipulating the html structure of the editor
WebView webView;
WebEngine webEngine;
...
StringBuilder script = new StringBuilder();
script.append("function eventFire(el, etype){");
script.append("if (el.fireEvent) {");
script.append("el.fireEvent('on' + etype);");
script.append("} else {");
script.append("var evObj = document.createEvent('Events');");
script.append("evObj.initEvent(etype, true, false);");
script.append("el.dispatchEvent(evObj);");
script.append("}");
script.append("}");
script.append("eventFire(document.getElementsByTagName('html')[0], 'click');");
webEngine.executeScript(script.toString());
Is there a way to do it? Thanks for your help.