JetBrains / jcef

A simple framework for embedding Chromium-based browsers into Java-based applications.
Other
227 stars 37 forks source link

Non-US keyboard layouts don't work properly in macOS in OSR mode #17

Closed cijaaimee closed 1 year ago

cijaaimee commented 1 year ago

Describe the bug When a key event is sent to CEF using offscreen rendering, the native code will only bind keys in the standard US layout when in macOS. This is because the code in charge of obtaining the virtual keycode is hardcoded to only work with this layout.

To Reproduce Steps to reproduce the behavior:

Create a browser in OSR mode. Type any key that isn't part of the US keyboard layout (e.g. á, ñ`). You'll see that the key is ignored. This does not occur when OSR is disabled. Expected behavior When typing, the key event should be forwarded to CEF.

Screenshots

Versions (please complete the following information):

OS: MacOS 13.0.1 Java Version: OpenJDK 17 JCEF Version: 4a605f4 CEF Version: 110.0.25 Additional context Does the problem reproduce with the JCEF simple or detailed sample application at the same version? Yes.

Does the problem reproduce with the CEF cefclient or cefsimple sample application at the same version? Yes.

Does the problem reproduce with Google Chrome at the same version? No.

Add any other context about the problem here. Here's an useful discussion on how to implement layout-independent char->keycode translation: https://stackoverflow.com/questions/1918841/how-to-convert-ascii-character-to-cgkeycode/1971027#1971027

ujpv commented 1 year ago

Hi @Grinderwolf, I think I recently fixed it for https://github.com/JetBrains/jcef. I've just checked it. It works for Turkish and Russian layouts.

Are you sure that it's an issue with this fork? There is also https://github.com/chromiumembedded/java-cef. Keyboard events are handled slightly differently there.

cijaaimee commented 1 year ago

Hi @Grinderwolf, I think I recently fixed it for https://github.com/JetBrains/jcef. I've just checked it. It works for Turkish and Russian layouts.

Are you sure that it's an issue with this fork? There is also https://github.com/chromiumembedded/java-cef. Keyboard events are handled slightly differently there.

I've just tried using the dev branch and it works, so I'm closing this issue. Thanks @ujpv!

PS: Are there any plans of merging any of the fixes from dev into master? I think it'd be useful to at least have some note on the readme mentioning this branch because I hadn't even noticed it exists.

ujpv commented 1 year ago

@Grinderwolf , Thank you for verifying! Yes, I think we should make our dev branch more visible. Probably it must be the default one.