pharo-project / pharo

Pharo is a dynamic reflective pure object-oriented language supporting live programming inspired by Smalltalk.
http://pharo.org
Other
1.21k stars 356 forks source link

Pharo keyboard input broken for dead key inputs #17338

Open pavel-krivanek opened 2 weeks ago

pavel-krivanek commented 2 weeks ago

Bug description Starting with the build 311 of Pharo 13, the dead key input is not working correctly anymore which breaks input of characacters like ^ using German or Czech keyboard on Windows. You write first combination AltGr+3 followed by Space. It is clearly an image error, not related to VM.

It is probably introduced by this commit: https://github.com/pharo-project/pharo/commit/9b55ea408a6ac583655e07c12d63f26dd64c6f87

To Reproduce Steps to reproduce the behavior:

  1. Switch to Czech or German keyboard layout, open Playground
  2. AltGr+3 followed by Space
  3. a space is written instead of ^

Other characters using the same input method do not as well.

Ducasse commented 1 week ago

Thanks pavel. We should write a test. How can we reproduce AltGr+3 on a non windows keyboard?

pavel-krivanek commented 1 week ago

Good question :)

However, I realised the problem stems from elsewhere. Now it is not easy to know what was integrated into a particular build so I had to compare the image sources directly of build 310 and 311.

The issue comes from Rubric, and it is caused by the new content of RubTextEditor>>#space: which is

space: aKeyboardEvent
    "Append a space to the stream of characters and commit the undo/redo transaction.
    This allows to manage undo/redo at a per-word granularity"

    "We are consuming the space keydown event, do not send a keypress for it"
    aKeyboardEvent supressNextKeyPress:  true.

    self closeTypeIn.
    self addString: String space.
    self unselect.
    ^false

when I try:

space: aKeyboardEvent 
    ^false

then dead keys input works. And I quickly looked at aKeyboardEvent object to see if it differs somehow in these two cases and no, they have the very same content so it will not be casy to distinquish the dead key input.

guillep commented 1 week ago

HA! I see, thanks @pavel-krivanek for the debugging.

There should be something to differentiate them. In fact, the problem is that we are supressing the upcoming keypress, right?

Maybe we can try with something like:

space: aKeyboardEvent
    "Append a space to the stream of characters and commit the undo/redo transaction.
    This allows to manage undo/redo at a per-word granularity"

    self closeTypeIn.
    self unselect.
    ^false

?

pavel-krivanek commented 1 week ago

In fact, the problem is that we are supressing the upcoming keypress, right?

yes, exactly, so like that, it work. But the problem with your proposed code is then that id does unselect before the space is written. So it does not work correctly in case you select a range and press space. It probably should do just

space: aKeyboardEvent
    "Append a space to the stream of characters and commit the undo/redo transaction.
    This allows to manage undo/redo at a per-word granularity"

    self closeTypeIn.
    ^false
guillep commented 1 week ago

Looks like a good patch :)