Skip to content

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

Draft
sjml wants to merge 1 commit into
floooh:masterfrom
sjml:master
Draft

Don't consume keyboard events if mouse is over imgui window#575
sjml wants to merge 1 commit into
floooh:masterfrom
sjml:master

Conversation

@sjml

@sjml sjml commented Oct 23, 2021

Copy link
Copy Markdown
Contributor

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

floooh commented Oct 27, 2021

Copy link
Copy Markdown
Owner

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

sjml commented Oct 27, 2021

Copy link
Copy Markdown
Contributor Author

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