ocornut / imgui

Dear ImGui: Bloat-free Graphical User interface for C++ with minimal dependencies
MIT License
61.15k stars 10.31k forks source link

AddKeyEvent not working #7301

Closed JD31 closed 9 months ago

JD31 commented 9 months ago

Version/Branch of Dear ImGui:

v1.89.9

Back-ends:

WebGPU

Compiler, OS:

msvc2022 or Emscripten

Full config/build information:

No response

Details:

I have a simple InputText that I want to interact with with the keyboard.
I am able to push events with AddInputCharacter() (for example AddInputCharacter('Z')).
But I would like to use the key based API but I don't manage to make it run (io.AddKeyEvent(ImGuiKey_Z, down) does not send anything to the text field)

Screenshots/Video:

No response

ocornut commented 9 months ago

Keys and Characters are different concepts. A regular backend when you press Z would send both a io.AddKeyEvent(ImGuiKey_Z, ...) event and a AddInputCharacter('Z'). You are likely to need to send characters if you want them to be listened to by an InputText() widget.

I have a simple InputText that I want to interact with with the keyboard.

I'm not sure what this means and we may not be providing you the best answers if we don't understand what you are trying to do.

JD31 commented 9 months ago

I have my own cross-platform window system (WE don't use sdl or glfw). The rendering backend is webgpu (dawn based), and dear imgui works perfectly well for rendering. I connected with succes mouse events between our window system and dear imgui. Now I am connecting the keyboard events. My thoughts (wrong with the lights you gave before) was that using the keycode based api would be enough. I understand I need to feed as well the character based api. Doing this works. Thank you.