-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
Modifier keys remain in pressed state after triggering screen snipping function #1011
Comments
Do you know if that happens only when doing a screenshot, or does it also happen if the window loses focus in any other way? |
I can't think of a way to make it lose focus and get back to the window without letting it regain focus (which fixes said issue)... |
Before the screenshot is taken |
So I "fixed" it with this insanely ugly patch but I'm not sure a better way to do this other than just emit events for every modifier every time. diff --git a/src/cocoa_window.m b/src/cocoa_window.m
index 6f8aa978..0ea3209c 100644
--- a/src/cocoa_window.m
+++ b/src/cocoa_window.m
@@ -586,6 +586,15 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
action = GLFW_RELEASE;
_glfwInputKey(window, key, [event keyCode], action, mods);
+
+ _glfwInputKey(window, GLFW_KEY_LEFT_SHIFT , _glfw.ns.scancodes[GLFW_KEY_LEFT_SHIFT ], mods & GLFW_MOD_SHIFT ? GLFW_PRESS : GLFW_RELEASE, mods);
+ _glfwInputKey(window, GLFW_KEY_LEFT_CONTROL , _glfw.ns.scancodes[GLFW_KEY_LEFT_CONTROL ], mods & GLFW_MOD_CONTROL ? GLFW_PRESS : GLFW_RELEASE, mods);
+ _glfwInputKey(window, GLFW_KEY_LEFT_ALT , _glfw.ns.scancodes[GLFW_KEY_LEFT_ALT ], mods & GLFW_MOD_ALT ? GLFW_PRESS : GLFW_RELEASE, mods);
+ _glfwInputKey(window, GLFW_KEY_LEFT_SUPER , _glfw.ns.scancodes[GLFW_KEY_LEFT_SUPER ], mods & GLFW_MOD_SUPER ? GLFW_PRESS : GLFW_RELEASE, mods);
+ _glfwInputKey(window, GLFW_KEY_RIGHT_SHIFT , _glfw.ns.scancodes[GLFW_KEY_RIGHT_SHIFT ], mods & GLFW_MOD_SHIFT ? GLFW_PRESS : GLFW_RELEASE, mods);
+ _glfwInputKey(window, GLFW_KEY_RIGHT_CONTROL, _glfw.ns.scancodes[GLFW_KEY_RIGHT_CONTROL], mods & GLFW_MOD_CONTROL ? GLFW_PRESS : GLFW_RELEASE, mods);
+ _glfwInputKey(window, GLFW_KEY_RIGHT_ALT , _glfw.ns.scancodes[GLFW_KEY_RIGHT_ALT ], mods & GLFW_MOD_ALT ? GLFW_PRESS : GLFW_RELEASE, mods);
+ _glfwInputKey(window, GLFW_KEY_RIGHT_SUPER , _glfw.ns.scancodes[GLFW_KEY_RIGHT_SUPER ], mods & GLFW_MOD_SUPER ? GLFW_PRESS : GLFW_RELEASE, mods);
}
- (void)keyUp:(NSEvent *)event |
OS: MacOS 10.12.4
GLFW Version: GLFW 3.3.0 Cocoa NSGL
When I trigger the MacOS screen snipping function (shift-cmd-4 or shift-cmd-4+space), then
glfwGetKey(window, GLFW_KEY_LEFT_SHIFT)
andglfwGetKey(window, GLFW_KEY_LEFT_SUPER)
will continuously reportGLFW_PRESS
each frame.I've found two ways to reset the key state:
The text was updated successfully, but these errors were encountered: