aseprite / laf

A C++ library to create desktop applications
https://aseprite.github.io/laf/
MIT License
276 stars 60 forks source link

Fix Caps Lock has no effect on macOS #6

Closed ayuusweetfish closed 5 years ago

ayuusweetfish commented 5 years ago

Hi! Hope this can be of a little help (^ ^;)

It is a not-so-elegant workaround — I cannot find much information on how UCKeyTranslate() works, and this is the only way I can get the outcome correct so far. For now it seems that UCKeyTranslate() ignores the Caps Lock flag without Shift, and reads it with Shift, hence always disabling its function. I don't know the reason behind it, and I might, might be terribly wrong… I'd appreciate if anyone can provide a deeper insight into it!

Btw, this can fix aseprite/aseprite#1876.

dacap commented 5 years ago

Hi @kawa-yoiko! Thanks for your help on this one. As you said this looks a little hacky, the main issue with this patch is that we could introduce a new problem: Caps lock will act like Shift, so numbers will write symbols (1 -> !, 2 -> @, etc.) which is not desired.

I've tried to find an alternative solution and Chromium code was really helpful. You can find the fix here 75c2c3c5e98f7de2248a704f8e9fe5cd78722474. Thanks anyway for your PR!

ayuusweetfish commented 5 years ago

Ah indeed, I did not notice the new problem and did not know such an orderly approach existed. Thanks for your effort ^ ^