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

Always pass events to ImGui to solve keyRelease issues #62

Merged
merged 2 commits into from
Jan 10, 2024

Conversation

rolandhill
Copy link
Contributor

This PR always sends keyboard events to ImGui regardless of the state of io.WantCaptureKeyboard. io.WantCaptureKeyboard is used to determine whether the keyboard event has been handled.

These changes are in line with ImGui recommendations and solve the issue of io.WantCaptureKeyboard being false after Enter is pressed (currently handled by special code in SendEventsToImGui::apply(vsg::KeyReleaseEvent& keyRelease) ). It also solves the not-yet-documented issue where the user loses control of dialogs because the Tab key constantly repeats because the Tab KeyRelease event is missed because io.WantCaptureKeyboard becomes false prematurely.

The ImGui FAQ at https://github.com/ocornut/imgui/blob/master/docs/FAQ.md#q-how-can-i-tell-whether-to-dispatch-mousekeyboard-to-dear-imgui-or-my-application stresses that you should always send events to ImGui.

image

The PR also removes the special KeyRelease code (originally added by me) to handle Enter because it is no longer needed.

Tested on Kubuntu with VSG master libraries pulled today. Note that using Tab to navigate through dialogs also requires the following during setup
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard | ImGuiConfigFlags_NavNoCaptureKeyboard;

@robertosfield robertosfield merged commit b5b4f8f into vsg-dev:master Jan 10, 2024
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

Successfully merging this pull request may close these issues.

2 participants