On Wed, 14 May 2025 15:31:46 GMT, Martin Fox <m...@openjdk.org> wrote:

> Under the hood the Keyman input method appears as a US English keyboard 
> layout. The characters attached to an NSEvent are always US English Roman 
> even if the selected Keyman layout is, say, Hebrew or Dvorak. Keyman sends 
> the correct Hebrew or Dvorak character to insertText:replacementRange: 
> instead.
> 
> This PR special-cases the Keyman layout, detecting it using the same method 
> that AWT does. When Keyman is active Glass records the insertText: character 
> and uses that when sending out KeyEvents.

A second shot at getting the Keyman input method working. In this version we 
detect that Keyman is active at the very beginning of key down handling. If 
Keyman is active we drop any key event that doesn’t lead to a call to one of 
the NSTextInputClient methods. Character-generating keys are caught inside 
`insertText:replacementRange:`. All other keys (like Home, Backspace, Delete, 
function keys, etc.) are caught in `doCommandBySelector:`. Note: AWT uses a 
different heuristic; it captures keys like Home in `performKeyEquivalent:`.

Under the hood Keyman is using some Roman layout (for me it’s US English) and 
all keyboard shortcuts will be based on that layout and not the Keyman layout. 
So if you test with Dvorak shortcuts like Cmd+X require you to hit X in the US 
English (QWERTY) location, not the Dvorak one. This is a general problem with 
Keyman that affects all applications.

A keystroke that generate more than one UTF-16 code unit will be processed as a 
JavaFX InputMethodEvent rather than a KeyEvent. This is old logic that’s been 
in JavaFX for a long time that I didn’t want to re-visit. You’ll see this with 
the Himyarit Musnad layout.

I tried to isolate the Keyman logic as much as possible. I’ve done some testing 
with Himyarit Musnad, Hebrew, and ISIS-Devanagari. It won’t work the newer 
Guatami Devanagari since it keeps sending backspaces to erase previous 
characters. That layout doesn’t seem to work well anywhere.

-------------

PR Comment: https://git.openjdk.org/jfx/pull/1805#issuecomment-2887775192

Reply via email to