Note that there are some explanatory texts on larger screens.

plurals
  1. POWebview with contenteditable cannot be focused programmatically
    primarykey
    data
    text
    <p>Trying to do a requestFocus() on the WebView does not work until the user has first clicked on the control.</p> <p>I know this must be possible as htmlEditor can be focused this way (and I suspect it is based on a contenteditable WebView).</p> <p>I am coding my own specialized htmlEditor using a webview with "contenteditable" and I would really like to be able to focus it like I can do with the standard htmlEditor.</p> <p>I believe this must be an issue with Javafx and I have already submitted it to Jira, but I wonder if anyone can think of a work-around for this.</p> <p><strong>UPDATE</strong>: Issue number in jira: RT-21695</p> <p>Short demostration code:</p> <pre><code>/* Demo webview */ public class WebViewConteneditableDemo extends Application { String initialEditview = "&lt;html&gt;&lt;head&gt;" + "&lt;/head&gt;&lt;body contenteditable='true'&gt;" +"&lt;/body&gt;&lt;/html&gt;"; /** * @param args the command line arguments */ public static void main(String[] args) { launch(args); } @Override public void start(Stage primaryStage) { primaryStage.setTitle("Webview focus demo"); final WebView editor = new WebView(); Button btn = new Button(); btn.setText("Test Webview focus"); btn.setOnAction(new EventHandler&lt;ActionEvent&gt;() { @Override public void handle(ActionEvent event) { editor.requestFocus(); } }); BorderPane root = new BorderPane(); root.setTop(btn); root.setCenter(editor); editor.getEngine().loadContent(initialEditview); primaryStage.setScene(new Scene(root, 500, 450)); primaryStage.show(); } </code></pre> <p>}</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload