Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I have succedded doing something similar.<br> I figured I can share some of the basic clues that allowed me to achieve it.</p> <ol> <li><p>Resize the whole WebView. For that, the whole WebView must be an editable html page. You achive that by setting contenteditable to true:</p> <p>&lt;body contenteditable='true' id='content'>&lt;/body></p></li> <li><p>You can have a context menu over a webview. But it is something tricky, as you must first disable the original context menu associated to it.</p> <p>WebView editView;</p> <p>...</p> <p>EventDispatcher originalDispatcher = editView.getEventDispatcher(); editView.setEventDispatcher(new WebmenuEventDispatcher(originalDispatcher));</p></li> </ol> <p>And this is the event dispatcher class: </p> <pre><code> public class WebmenuEventDispatcher implements EventDispatcher { private EventDispatcher originalDispatcher; public WebmenuEventDispatcher(EventDispatcher originalDispatcher) { this.originalDispatcher = originalDispatcher; } @Override public Event dispatchEvent(Event event, EventDispatchChain tail) { if (event instanceof MouseEvent) { MouseEvent mouseEvent = (MouseEvent) event; if (MouseButton.SECONDARY == mouseEvent.getButton()) { mouseEvent.consume(); // Show our own menu cmEdit.show(editView.getScene().getWindow(), mouseEvent.getScreenX(), mouseEvent.getScreenY()); } } return originalDispatcher.dispatchEvent(event, tail); } } </code></pre> <p>Now, for setting the font from within that menu, you need a bidirectional Java&lt;->javascript bridge and use some javascript in the webview side.</p>
 

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