Each Enter or Backspace key press will repeat several times in GLFW.
I'm using GLFW 3.3 with GL3 backend under MacOS v10.15.1.
In TextEditor, each Enter or Backspace key press will generate several key press events which makes the TextEditor nearly unusable.
I compiled nuklear with below defines:
NK_INCLUDE_FIXED_TYPES: 1
NK_INCLUDE_STANDARD_IO: 1
NK_INCLUDE_DEFAULT_ALLOCATOR: 1
NK_INCLUDE_VERTEX_BUFFER_OUTPUT: 1
NK_INCLUDE_FONT_BAKING: 1
NK_INCLUDE_DEFAULT_FONT: 1
NK_KEYSTATE_BASED_INPUT: 1
How to fix it?
This is probably related to https://github.com/Immediate-Mode-UI/Nuklear/pull/14, as before the PR when a mouse button was clicked, it wasn't consumed. I'm assuming the same is the case with keyboard input (I've not done anything related to editable text yet, so can't confirm this statement yet). The key is "down" in the nk_context even though it is already consumed by the text input, but will remain in that state until the key up event is called. This could potentially be solved the same way as mouse input; by adding a bool per key that is reset when the key is released and set when the key is consumed.
Has this problem not been solved yet? I have the same problem windows + glfw3 + GL3
I think glfw might be the problem here. Nuklear uses glfw char callbacks for normal characters. Special characters like backspace and up key are not reported in the glfw char callback. So Nuklear uses glfwGetKey for all special characters, which is called every time nk_glfw3_new_frame() is called. And when special characters are held down, nk_edit_string() modifies the string in the textbox everytime that it is called.
Solutions:
1. #define NK_KEYSTATE_BASED_INPUT in your project
this makes it so whenever you press down on a special key, the key is only reported once. But this means you
cannot hold down backspace to delete a bunch of text.
2. make nuklear use key callback for all characters?
idk. I don't know much about nuklear and glfw. But I wanna try and help
@telephone001 thanks! We maintainers & devs are fully booked in our lifes so any help is highly appreciated.