benfry / processing4

Processing 4.x releases for Java 17
https://processing.org
Other
1.33k stars 239 forks source link

Cannot type quotes with an international keyboard on MacOS #322

Open davantwillert opened 2 years ago

davantwillert commented 2 years ago
## Description

I would like to type single and double quotes instead of having to copy/past the characters

Expected Behavior

I expect to see a " and ' character when I type it as happens in Word, this browser and all other applications

Current Behavior

When I type a single or double quote on an international keyboard (so with a space after the character), only the space appears

Steps to Reproduce

  1. Type a quote in the editor with an international keyboard. Accented characters typed by two characters and single and double quote by those characters and then space.
  2. I can type single and double quotes in the Save As Dialog (probably a native Dialog)

Your Environment

Possible Causes / Solutions

Florito2323 commented 2 years ago

Exact same problem here. (MacOS BigSur), also with U.S. International keyboard. Currently I get around by adding a U.S. keyboard. With this I can program with single and double quotes again :)

benfry commented 2 years ago

Yikes, sounds like a Java bug—may be fixed with the updated JDK that will be in 4.0 beta 3.

But if anyone can test/look into it further, that'd be really helpful—I don't have an International Keyboard to test with, unfortunately.

morfav commented 2 years ago

I had a quick look at this.

To reproduce this issue, it is not necessary to have an international keyboard. It is enough to add it as one of the keyboards/languages in settings. Then, right-clicking on the language symbol in the top right, select 'Show Keyboard Viewer'. This will display the international keyboard:

image

The problematic characters are the ones that are highlighted in orange. They are called dead keys (a modifier key pressed with another key to enter a letter with a diacritical mark). With international keyboard selected, just press the single quote mark and compare to behavior in TextEdit. Processing ignores the key press whereas a single quote appears in TextEdit (the complication is that depending on the next button press, it's necessarily to display either quote (if space is pressed) or a modified character - if ' and then 'a' is typed, the character becomes á).

I noticed that when a 'normal' key is pressed (quote on non-international keyboard), 3 events are triggered (key pressed, key typed and key released). Typing quote with international keyboard only seems to generate a key released event.

benfry commented 2 years ago

Thanks for looking into it, that's really helpful.

Was able to reproduce the problem here, and it comes down to how the events are passed to Processing. As a workaround, go to Preferences and check the "Enable complex text input" box, which is just a shorthand for enabling these multi-stroke key events (more commonly seen in non-Roman languages).

So it'll still need a fix—I'd like to see whether we can leave that turned on all the time, for instance—but hopefully this can get things working for you in the meantime.