Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Alt handling to allow layout translation #316

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

najlkin
Copy link
Contributor

@najlkin najlkin commented Sep 5, 2024

Fixed Alt handling to allow key translation for different layouts by passing modifiers to the text input event.

👉 Please test on different platforms. On Windows+WSL or Linux: Left Alt does not translate the key and Right Alt (AltGr) does translate the key.

❓ This is a possible fix for #311 .

@tzanio
Copy link
Member

tzanio commented Sep 12, 2024

This doesn't seem to work on Mac -- I tested e.g. Alt+c and nothing happens

@najlkin
Copy link
Contributor Author

najlkin commented Sep 12, 2024

Left or right Alt? ... if they are on Mac 😅

@tzanio
Copy link
Member

tzanio commented Sep 12, 2024

Either left or right option key (there is no Alt on Mac)

@najlkin
Copy link
Contributor Author

najlkin commented Sep 12, 2024

Hmm, that matches, I have found online that there are special symbols mapped to keys on Mac without making a difference between left and right option. So the only way I see is to guard the condition for Mac to return the functionality with localized layouts at least for Linux and Windows users? 🤔

@najlkin
Copy link
Contributor Author

najlkin commented Sep 12, 2024

Ok, this is a more elegant solution and also works for Windows or Linux users who do not know the difference between left and right Alt 😁 . It stores the physical key from keyDown as a backup, so if translation of the key gives some weird symbol on Mac or accidentally use the wrong Alt on Windows or Linux with some localized layout 😏 , it returns to handling of that one in textInputevent (like if it was in keyDown) 😉 .

@tzanio
Copy link
Member

tzanio commented Sep 13, 2024

Maybe I am doing something wrong, but this also doesn't work on a Mac: "option+c" acts like "shift+c" and similarly for "option+a"

@najlkin
Copy link
Contributor Author

najlkin commented Sep 13, 2024

Ahh, I stored the physical key, which is always capital 😅 . Now it must work, otherwise... 🤪

@tzanio
Copy link
Member

tzanio commented Sep 13, 2024

Ok, it seems to work with 031ca5c

@v-dobrev
Copy link
Member

I'm testing this with a native Windows build with MSVC and both Alt+a and Ctrl+a do not work. I suspect Ctrl+a does not work on other platforms either since it does not generate text-input event.

@v-dobrev
Copy link
Member

Just tested on Mac and can confirm that Ctrl+a does not work there.

@najlkin
Copy link
Contributor Author

najlkin commented Sep 19, 2024

Hmm, that Ctrl can be separated, because it is not used for characters translation, but that Alt is a trouble 🤔 . Have you tried both, left and right?

@najlkin
Copy link
Contributor Author

najlkin commented Sep 19, 2024

If it does not work with neither of them, we may let pass only right Alt to the text input event, because only that one does the translation anyway, so at least the left Alt will work on Windows 🤔 .

@najlkin
Copy link
Contributor Author

najlkin commented Sep 19, 2024

Ok, so I basically reverted that to handle Ctrl, Left Alt and Gui keys in the key down event as before. Only Right Alt is passed to the text input event as only that one does the translation of the characters anyway. So at least Left Alt should work on Windows now 😉 and I guess that Right Alt does not generate text input events as there is nothing mapped to the key by the layout. So when there will be something like with some localized layout, it will generate that event and will work as intended 👍 .

@najlkin
Copy link
Contributor Author

najlkin commented Sep 19, 2024

Btw, is Ctrl+A documented? I do not see it anywhere... 🤔

@v-dobrev
Copy link
Member

Hmm, that Ctrl can be separated, because it is not used for characters translation, but that Alt is a trouble 🤔 . Have you tried both, left and right?

Neither the left nor the right Alt are generating text-events on Windows with the MSVC build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants