Mouse press ignored after key press

I register the following events:

        glfwSetKeyCallback(window, key_callback);
        glfwSetMouseButtonCallback(window, mouse_press_callback);

The mouse press event works fine but as the topic says I don’t get a callback for a button press straight after a key press - a second press does get through. Note it also works if I move the mouse after the keypress (and before a button press).

This is on windows.

Jon

I can’t replicate this on my Windows system (Windows 10 x64 with GLFW 3.2 from github), and also haven’t seen this before.

Running events.c from the tests gives me the following output (running events > events.txt) :

0000001a to 1 at 0.936: Cursor position: 397.000000 309.000000
0000001b to 1 at 0.944: Cursor position: 396.000000 308.000000
0000001c to 1 at 0.952: Cursor position: 394.000000 306.000000
0000001d to 1 at 0.960: Cursor position: 394.000000 305.000000
0000001e to 1 at 0.968: Cursor position: 394.000000 304.000000
0000001f to 1 at 7.627: Key 0x004b Scancode 0x0025 (K) (K) (with no mods) was pressed
00000020 to 1 at 7.627: Character 0x0000006b (k) with modifiers (with no mods) input
00000021 to 1 at 7.627: Character 0x0000006b (k) input
00000022 to 1 at 7.750: Key 0x004b Scancode 0x0025 (K) (K) (with no mods) was released
00000023 to 1 at 7.825: Mouse button 0 (left) (with no mods) was pressed
00000024 to 1 at 7.940: Mouse button 0 (left) (with no mods) was released
00000025 to 1 at 8.013: Key 0x004b Scancode 0x0025 (K) (K) (with no mods) was pressed
00000026 to 1 at 8.013: Character 0x0000006b (k) with modifiers (with no mods) input
00000027 to 1 at 8.013: Character 0x0000006b (k) input
00000028 to 1 at 8.127: Key 0x004b Scancode 0x0025 (K) (K) (with no mods) was released
00000029 to 1 at 8.244: Mouse button 0 (left) (with no mods) was pressed
0000002a to 1 at 8.368: Mouse button 0 (left) (with no mods) was released
0000002b to 1 at 8.397: Key 0x004b Scancode 0x0025 (K) (K) (with no mods) was pressed
0000002c to 1 at 8.397: Character 0x0000006b (k) with modifiers (with no mods) input
0000002d to 1 at 8.397: Character 0x0000006b (k) input
0000002e to 1 at 8.512: Key 0x004b Scancode 0x0025 (K) (K) (with no mods) was released
0000002f to 1 at 8.618: Mouse button 0 (left) (with no mods) was pressed
00000030 to 1 at 8.764: Mouse button 0 (left) (with no mods) was released

Here I press and release the K key and then press and release mouse button 0, but other combinations also work.

Could you run the events.c test and see what you get? It’s available in the GLFW source package or Github repo.

I’ve reproduce it with events.c, seems to go wrong on the 2nd attempt (see my added comments in []):

Library initialized
Creating windowed mode window 1 (640x480)
Main loop starting
00000000 to 1 at 0.054: Window refresh
00000001 to 1 at 3.038: Window position: 173 184

0000003d to 1 at 9.329: Key 0x0046 Scancode 0x0021 (F) (F) (with no mods) was pressed
0000003e to 1 at 9.341: Character 0x00000066 (f) with modifiers (with no mods) input
0000003f to 1 at 9.346: Character 0x00000066 (f) input
00000040 to 1 at 9.437: Key 0x0046 Scancode 0x0021 (F) (F) (with no mods) was released
[First button test worked]
00000041 to 1 at 10.415: Mouse button 0 (left) (with no mods) was pressed
00000042 to 1 at 12.124: Mouse button 0 (left) (with no mods) was released
00000043 to 1 at 12.652: Mouse button 0 (left) (with no mods) was pressed
00000044 to 1 at 13.120: Mouse button 0 (left) (with no mods) was released
00000045 to 1 at 13.609: Key 0x0046 Scancode 0x0021 (F) (F) (with no mods) was pressed
00000046 to 1 at 13.619: Character 0x00000066 (f) with modifiers (with no mods) input
00000047 to 1 at 13.627: Character 0x00000066 (f) input
00000048 to 1 at 13.733: Key 0x0046 Scancode 0x0021 (F) (F) (with no mods) was released
[Pressed button here - no events]
00000049 to 1 at 16.464: Cursor position: 333.000000 75.000000
0000004a to 1 at 16.489: Cursor position: 333.000000 76.000000
0000004b to 1 at 16.562: Cursor position: 333.000000 77.000000
0000004c to 1 at 16.981: Mouse button 0 (left) (with no mods) was pressed
0000004d to 1 at 17.127: Mouse button 0 (left) (with no mods) was released

Jon

Just tested a bit more and there seems to be a time based issue. If I wait for a second or two after the key press the button press works, similarly if I press the button quickly straight after the key press it doesn’t register 2 or 3 presses.

Jon

If this behaviour doesn’t happen on other non GLFW applications (i.e. it’s not a system issue), and it happens with the latest GLFW from Github then you could consider filling an issue.