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

Each Enter or Backspace key press will repeat several times in GLFW. #26

Open
AllenDang opened this issue Dec 17, 2019 · 4 comments
Open

Comments

@AllenDang
Copy link

AllenDang commented Dec 17, 2019

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?

@Nielsbishere
Copy link
Contributor

This is probably related to #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.

@00BUG00
Copy link

00BUG00 commented Dec 2, 2021

Has this problem not been solved yet?
I have the same problem
windows + glfw3 + GL3

@telephone001
Copy link

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

@dumblob
Copy link
Member

dumblob commented Jun 9, 2023

@telephone001 thanks! We maintainers & devs are fully booked in our lifes so any help is highly appreciated.

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

No branches or pull requests

5 participants