I'm switching from JEditorPane
to WebEngine
(JavaFX).
I used to lock the text highlighting(selecting) in JEditorPane
as following.
my_editor.setEditable(false);
my_editor.getInputMap().put(KeyStroke.getKeyStroke("control C"), "none");
Now I like to do the same with WebEngine
, how may I do this? disabling copy, highlighting and editing mode. Thanks.
If you want to disable copy, highlighting and editing from JavaFX, without the use of Javascript, one way to do it is by trapping the events and deal accordingly with them, leaving the rest of the options intact.
Let's use an event dispatcher to filter a few events:
For key events:
For Mouse events:
(Others could be added if you need to)
Now on your scene, disable context menu to avoid copy/paste options, find the content area of the webview without the scrollbars, if any, and set the custom event dispatcher.