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

keyReleaseEvent not triggered after printscreen on OSX #622

Closed
jvannugteren opened this issue Jul 11, 2023 · 6 comments
Closed

keyReleaseEvent not triggered after printscreen on OSX #622

jvannugteren opened this issue Jul 11, 2023 · 6 comments

Comments

@jvannugteren
Copy link
Contributor

jvannugteren commented Jul 11, 2023

Hi Mosra, In OSX the keybind for making a screenshot of a section of the screen is: cmnd + shift + 5. When I do this the keyReleaseEvent is not triggered leaving shift and cmnd pressed forever (or until cmnd + shift is pressed again without screenshot). This can easily be verified in the IMGUI demo. Go to the "Inputs and Focus" section and make a screenshot using the keyboard shortcut, while the window is active. The "keys down" will show that the shift and cmnd keys are not released. I'm using an SDL2 application platform. Thanks in advance for having a look.

@mosra
Copy link
Owner

mosra commented Jul 12, 2023

Hi,

I vaguely remember that various other people had this problem too, and IIRC it has something to do with how the OS treats this. Here's a similar bugreport for GLFW, from 2017: glfw/glfw#1011

Unfortunately I wasn't able to find any such bugreport for SDL, but I suppose it's the same case. Not sure how to fix this apart from querying the key state directly, honestly. A somewhat related discussion is here: mosra/magnum-integration#99

@jvannugteren
Copy link
Contributor Author

Hmm yes it is exactly the same as the GLFW issue you mention. Indeed cmnd-shift-3 does not cause any issues (only cmnd-shift-5). I think OSX opening a screenshot UI steals away focus from the application and then forgets to send the keyReleaseEvent. So its an Apple issue? Maybe the screenshot triggers some event in SDL, for example window event, that allows me to override the ImGui keystate. Otherwise querying the keystate in each render loop may work as well. Feels a bit excessive though. I'll have a look.

@jvannugteren
Copy link
Contributor Author

Another discovery. When the 5 gets pressed to finish the key combination, the keyPressEvent is not called either.

@jvannugteren
Copy link
Contributor Author

This issue has fixed itself. Thanks.

@mosra
Copy link
Owner

mosra commented Apr 12, 2024

Nice. Are you able trace that fix to a SDL commit, just in case someone else hits a similar problem?

@jvannugteren
Copy link
Contributor Author

Not easy to find. Might also have been a MacOS update that fixed it. I'll keep searching.

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

No branches or pull requests

2 participants