RFR: 8087700: [KeyCombination, Mac] KeyCharacterCombinations behave erratically

Martin Fox mfox at openjdk.org
Wed Nov 15 17:07:46 UTC 2023


On Wed, 15 Nov 2023 00:54:26 GMT, Martin Fox <mfox at openjdk.org> wrote:

>> @beldenfox thank you.  I still not entirely sure what issue is being tested and how to fix it, between this PR and JBS.
>> For example, when I run the application listed in JBS description with your fix, I get one "HI" - is it expected?  (I also get 1 "HI" on Windows)
>> 
>> On macOS, new KeyCodeCombination(KeyCode.MINUS, KeyCombination.CONTROL_DOWN) does not equal to new KeyCharacterCombination("-", KeyCombination.CONTROL_DOWN) (same on Windows)
>> 
>> Interestingly, Ctrl+- on macOS with the US keyboard produces
>> 
>> 
>> KeyEvent{type=KEY_PRESSED, character=<\u00>, text=, code=CONTROL, control}
>> KeyEvent{type=KEY_PRESSED, character=<\u00>, text=, code=MINUS, control}
>> KeyEvent{type=KEY_TYPED, character=<\u1F>, text=, code=UNDEFINED, control}
>> KeyEvent{type=KEY_RELEASED, character=<\u00>, text=, code=MINUS, control}
>> KeyEvent{type=KEY_RELEASED, character=<\u00>, text=, code=CONTROL}
>> 
>> 
>> but on Windows, we don't get KEY_TYPED event:
>> 
>> 
>> KeyEvent{type=KEY_PRESSED, character=<\u00>, text=, code=CONTROL, control, shortcut}
>> KeyEvent{type=KEY_PRESSED, character=<\u00>, text=-, code=MINUS, control, shortcut}
>> KeyEvent{type=KEY_RELEASED, character=<\u00>, text=-, code=MINUS, control, shortcut}
>> KeyEvent{type=KEY_RELEASED, character=<\u00>, text=, code=CONTROL}
>> 
>> 
>> 
>> is this expected?
>> 
>> And yes, it would help if we can extract any other issues into their own tickets (unless they all being fixed by this change).
>> 
>> If I may make one suggestion - for the sake of reviewers - to re-phrase the JBS ticket in the format of
>> - steps to reproduce
>> - expected outcome
>> - observed outcome
>> 
>> it would help a lot!
>> 
>> Thanks!
>
> @andy-goryachev-oracle What keyboard layout do you normally use on Windows? And Mac? When talking about the behavior of punctuation this is a crucial bit of information.
> 
>> but on Windows, we don't get KEY_TYPED event:
>> is this expected?
> 
> When you hold down Ctrl and press a key the platform may or may not generate a low-ASCII control code. JavaFX has never tried to make the platforms consistent here, Glass just passes on whatever the OS generates. In any case the TextInputControls treat these TYPED events as nuisances, if you look in TextInputControlBehavior.java and read `defaultKeyTyped` you'll see how it tries to filter out control codes and anything else that looks like it was associated with a shortcut.

> @beldenfox thank you. I still not entirely sure what issue is being tested and how to fix it, between this PR and JBS. For example, when I run the application listed in JBS description with your fix, I get one "HI" - is it expected? (I also get 1 "HI" on Windows)

When you run the application in the JBS description and press Ctrl-'-' on the main keyboard (not the numeric keypad) you should see "HI" printed twice, once for the MINUS KeyCode combination and once for the '-' KeyCharacter combination. I'm not sure why that's not working for you on Windows with a U.S. layout. With that said, on Windows KeyCharacter combinations for punctuation can be uncertain unless you're running a build with PR #1264 which was just integrated.

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

PR Comment: https://git.openjdk.org/jfx/pull/1209#issuecomment-1812925964


More information about the openjfx-dev mailing list