On Mon, 13 Dec 2021 19:40:47 GMT, Martin Fox <d...@openjdk.java.net> wrote:

>> There was a mismatch between the way `get_glass_key` generated the Java key 
>> code for a given key press and how `getKeyCodeForChar` determined the key 
>> code for the matching character. For example, when pressing the plus sign on 
>> a US keyboard `get_glass_key` correctly generated `KeyCode.EQUALS` but 
>> `getKeyCodeForChar("+")` generated `KeyCode.PLUS`.
>> 
>> In this PR `getKeyCodeForChar` mirrors the behavior of `get_glass_key`; it 
>> determines which key the character lies on and generates a key code based on 
>> the unshifted character on  the same key.
>> 
>> I'm working on a more comprehensive test case that allows you to press any 
>> key on the keyboard and test whether a KeyCharacterCombination for that 
>> character will succeed or not. I've attached it to this thread. It might be 
>> worth submitting as a manual test case
>> [CharComboTest.txt](https://github.com/openjdk/jfx/files/7247265/CharComboTest.txt)
>> .
>
> Martin Fox has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   Learn-as-they-type approach to implementing getKeyCodeForChar

I can map from a character to a key but I haven’t found any way of verifying 
that the key is actually on the user’s keyboard. I can’t even filter them out 
as keypad keys, their `XkbKeyTypeIndex` puts them in the same class as the 
Space bar.

I’ve amended the PR to approach this the same way the Mac does. As the user 
types we query the key to determine which characters it can generate and stash 
them in a map. In `getKeyCodeForChar` we consult that map to answer the 
question.

This means both the Mac and Linux would be using the same brute force hack to 
get around the limitations of `getKeyCodeForChar`. I think it’s time for it to 
go. I’ve entered an alternate PR #694 that paves the way for retiring that call 
and replacing it with one that’s much easier to get right on all platforms. I 
would prefer to close this PR and focus on that one. Life is short.

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

PR: https://git.openjdk.java.net/jfx/pull/635

Reply via email to