Open guirak opened 1 year ago
That's very tricky at the moment. The Browser APIs to access the clipboard is still experimental (and only work after explicit approval by the user) But it should be implementable now. So it's something we should do when we have some time left.
Ok, good. Thank you.
I had trouble with copy-paste until I tried this:
KeyCombination copyKey = new KeyCodeCombination(KeyCode.C, KeyCombination.CONTROL_DOWN);
chatBox.addEventHandler(KeyEvent.KEY_PRESSED, keyEvent -> {
if(copyKey.match(keyEvent)) {
getWebAPI().executeScript("""
navigator.clipboard.writeText("%s");
""".formatted(chatBox.getSelectedText()));
}
});
@grubbcc If I remember correctly, this doesn't work on Safari. Generally, accessing the Clipboard is usually only limited possible. We have a utility class: https://github.com/JPro-one/JPro-Platform/blob/b0b83777b7de64af341933e62feddcfe1d269a75/jpro-routing/core/src/main/scala/one/jpro/platform/routing/CopyUtil.scala#L14 This class allows to setup "Copy on Click" You have to live with the restriction that the text to copy has to be known before the click.
It's also possible to access the Clipboard API: https://developer.mozilla.org/en-US/docs/Web/API/Clipboard_API But this requires approval by the user.
Hi Florian,
Is there a way to use something similar than the native Clipboard with JPRO ?
Thank you