RFR: 8150709: Mac OSX and German Keyboard Layout (Y/Z) [v6]

Martin Fox duke at openjdk.java.net
Tue Dec 21 16:47:21 UTC 2021


On Tue, 21 Dec 2021 16:42:40 GMT, Martin Fox <duke at openjdk.java.net> wrote:

>> This PR adds code to ensure that KeyCodeCombinations match KeyEvents as expected by more accurately mapping from a Mac key code to a Java key code based on the user’s active keyboard layout (the existing code assumes a US QWERTY layout). The new code first identifies a set of Mac keys which can produce different characters based on the user’s keyboard layout. A Mac key code outside that area is processed exactly as before. For a key inside the layout-sensitive area the code calls UCKeyTranslate to translate the key to an unshifted ASCII character based on the active keyboard and uses that to determine the Java key code.
>> 
>> When performing the reverse mapping for the Robot the code first uses the old QWERTY mapping to find a candidate key. If it lies in the layout-sensitive area the code then scans the entire area calling UCKeyTranslate until it finds a match. If the key lies outside the layout-sensitive area it’s processed exactly as before.
>> 
>> There are multiple duplicates of these bugs logged against Mac applications built with JavaFX.
>> 
>> https://bugs.openjdk.java.net/browse/JDK-8090257 Mac: Inconsistent KeyEvents with alternative keyboard layouts
>> https://bugs.openjdk.java.net/browse/JDK-8088120 [Accelerator, Mac] CMD + Z accelerator is not working with French keyboard
>> https://bugs.openjdk.java.net/browse/JDK-8087915 Mac: accelerator doesn't take into account azerty keyboard layout
>> https://bugs.openjdk.java.net/browse/JDK-8150709 Mac OSX and German Keyboard Layout (Y/Z)
>
> Martin Fox has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Bug fixes in Robot. Ensure symbols uncovered using Option are ignored.

I’ve updated the PR with three bug fixes that were in my queue. Sorry for not getting them in earlier. 

GetGlassKey (used by the Robot) - The table only covers US QWERTY and is missing entries for codes like PLUS or NUMBER_SIGN. There was a bug that prevented these codes from working on any layout. That’s been fixed. The same routine was also returning a bogus result when asked to look up UNDEFINED. That’s also been fixed.

getJavaCodeForMacKey - The probe for the Option key character was intended to find letters. In some instances it could find a symbol and use that to determine the code. This could cause a key like Ä or È to be given a code like SLASH. That’s been fixed to better match Windows and Linux where these keys are UNDEFINED.

I’ve attached a sanity test for the Robot code. Every time you press a key it just sends the KeyCode to a Robot and verifies that a TYPED event with the same code is received.

[RobotKeySanityTest.txt](https://github.com/openjdk/jfx/files/7756820/RobotKeySanityTest.txt)

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

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


More information about the openjfx-dev mailing list