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

Don't consume keyboard events if mouse is over imgui window #575

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sjml
Copy link
Contributor

@sjml sjml commented Oct 23, 2021

Creating an interface with Dear ImGui that only uses the mouse, I found I couldn't dismiss it with my designated toggle key because simgui_handle_event was returning true if the mouse pointer was positioned inside one of the rendered windows. I figure that if Dear ImGui's WantCaptureKeyboard flag is false, then simgui_handle_event should not return true for keyboard events.

This may be an intentional design thing, though... I'm still getting used to using Dear ImGui and maybe this is expected behavior. It felt like a bug to me, though. Even if it's something to be fixed, this might be a too ham-fisted way of going about it. (It works for my very limited case, though.)

Anyway, wanted to submit this just in case someone else gets puzzled by it as well.

@floooh
Copy link
Owner

floooh commented Oct 27, 2021

Ah interesting, I stumbled over a similar problem a few weeks ago in my visual6502remix project, and I worked around that outside of sokol_imgui.h by ignoring the return value of simgui_handle_event() and instead do my own thing in an event-handling-wrapper function:

floooh/v6502r@811c142

I need to think about this a bit more, but what's clear is that the current behaviour in simgui_handle_event() is too hardwired.

Thanks for the PR! I probably won't merge it as is, but I'll keep it open as reminder.

@floooh floooh marked this pull request as draft October 27, 2021 10:19
@sjml
Copy link
Contributor Author

sjml commented Oct 27, 2021

Thanks for the PR! I probably won't merge it as is, but I'll keep it open as reminder.

Sounds good! I didn't have any particular attachment to this solution, but glad it can be a useful nudge towards future improvement.

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