franz
May 19, 2020, 3:21pm
1
Hi,
Is it possible to check that the left or right Shift key is pressed when dragging a file onto a GLFW window?
I’ve tried the following but unsurprisingly it didn’t work (because Shift wasn’t pressed in the GLFW window):
const bool shift_pressed =
glfwGetKey(get_window(), GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS ||
glfwGetKey(get_window(), GLFW_KEY_RIGHT_SHIFT) == GLFW_PRESS;
I suspect that the answer is that what I’m asking isn’t possible, but I hope to be wrong!
Thanks for a great library.
Try setting the window focus with glfwFocusWindow(window);
in your drop callback, then checking the state. I just did a quick test and this seemed to work for me.
franz
May 19, 2020, 5:06pm
3
What works is the following workflow:
GLFW window is in focus.
User presses Shift, then drags & drops a file onto the window.
In this case, shift_pressed
is true
, even without adding
glfwFocusWindow(window);
What doesn’t work sadly is this:
User switches focus to another window (typically, Windows Explorer).
User drags & drops file onto GLFW window (which isn’t in focus).
In this case, shift_pressed
is false
, even with the glfwFocusWindow()
call.
I think the only way that latter workflow can work is by checking the keyboard status at the time of the file drop (and not relying on the key cache).