leaningtech / cheerpj-meta

Run Java 8 applications, libraries, applets, Java Web Start, and Oracle Forms on the web without legacy plugins.
https://labs.leaningtech.com/cheerpj
459 stars 21 forks source link

How about the keystrokes #194

Closed neoedmund closed 6 months ago

neoedmund commented 6 months ago

Wow, quite impressive about the Java Swing support. I can even run neoeedit.jar after recompile with jdk 8. But some keys are go through to the web browser, like, ,TAB , ctrl-H, ... , del, backspace, ... any options?

alexp-sssup commented 6 months ago

There is an optional cheerpjInit callback that let the user decides which additional shortcuts should be handled by Java rather than the browser: https://labs.leaningtech.com/cheerpj3/reference/cheerpjInit#overrideshortcuts

We do not automatically preventDefault all shortcuts since that would hijack legitimate ones that the user of the page might need. With the aforementioned callback the page author can refine the behavior.

neoedmund commented 6 months ago

after using

 await cheerpjInit({
         overrideShortcuts: function (e) {return true;}
        });

I cannot input a single character, something wrong? I suppose to have as many keys as possible because it's a text editor app.

alexp-sssup commented 6 months ago

Simply returning true won't work. By returning true you are causing CheerpJ to preventDefault() all events. By calling preventDefault() on all keydown/keyup events there will be no keypress events.

This is how the browser work, not something that CheerpJ can change.

You need to carefully select the combination you are interested in.

neoedmund commented 6 months ago

still impressive job, thank you!