Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Navigation does not lose focus when clicking on game background. #3344

Closed
rmitton opened this issue Jul 9, 2020 · 4 comments
Closed

Navigation does not lose focus when clicking on game background. #3344

rmitton opened this issue Jul 9, 2020 · 4 comments
Labels
bug focus nav keyboard/gamepad navigation

Comments

@rmitton
Copy link
Contributor

rmitton commented Jul 9, 2020

Version/Branch of Dear ImGui:

Version: 1.77
Branch: docking

My Issue/Question:

Clicking outside the UI (i.e. on the underlying void or dockspace) used to release the navigation. However, in commit d31fe97 a change was made where it no longer handles the case where g.HoveredRootWindow == NULL. This causes the navigation focus to remain stuck, causing io.WantCaptureKeyboard to stay set and prevents the game from receiving any inputs. (until Esc is pressed at least)

@ocornut ocornut added focus nav keyboard/gamepad navigation labels Jul 9, 2020
@DomGries
Copy link
Contributor

DomGries commented Jul 9, 2020

Personally I would prefer the current behavior with the newly arisen bugs fixed as this prevents keyboard/gamepad navigation being unusable after clicking on the background. Or at least maybe this can be made optional.

@batcholi
Copy link

batcholi commented Jul 11, 2020

A very simple fix is to capture the click callback and unfocus manually the imgui window via code...

// On Mouse Click Callback : 
if (!ImGui::IsAnyWindowHovered()) ImGui::SetWindowFocus(nullptr);

EDIT:
This does not work well because IsAnyWindowHovered() will return false while we are clicking on certain elements inside a window.... this removes the focus when we click on say a Checkbox... I would say this functionality is broken...

@ocornut
Copy link
Owner

ocornut commented Jul 13, 2020

Apologies for the issue and late reaction, will be looking at this.

@ocornut ocornut added the bug label Jul 13, 2020
ocornut added a commit that referenced this issue Jul 14, 2020
…31fe97.  (#3344, #2880)

This would be problematic e.g. in situation where the application relies on io.WantCaptureKeyboard flag being cleared accordingly.
@ocornut
Copy link
Owner

ocornut commented Jul 14, 2020

Pushed fix, this was incredibly dumb and thus equally puzzling and stressing to imagine that this bug went through.
We added some extra regression tests for it.

Minor note that:

Clicking outside the UI (i.e. on the underlying void or dockspace) used to release the navigation.

The "dockspace" part of that statement is wrong, unless you mean the transparent area of a "passthrough" dockspace but when you hover that you are not hovering the dockspace.

@domgho

Personally I would prefer the current behavior with the newly arisen bugs fixed as this prevents keyboard/gamepad navigation being unusable after clicking on the background.

There was a clear regression so we fixed it.
Some other threads discuss the possibility of adding more nav settings and i'll be happy to investigate them later (some applications are built over the premise that inputs should be shared between an underlying app and imgui stuff, some around the promise that navigation highlight should never ever be disabled, etc. we can work out alternate policies).

@ocornut ocornut closed this as completed Jul 14, 2020
Mernion pushed a commit to Mernion/imgui that referenced this issue Aug 3, 2020
…31fe97.  (ocornut#3344, ocornut#2880)

This would be problematic e.g. in situation where the application relies on io.WantCaptureKeyboard flag being cleared accordingly.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug focus nav keyboard/gamepad navigation
Projects
None yet
Development

No branches or pull requests

4 participants