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

Nav parameter for preventing focus loss by pressing ImGuiKey_Escape? #8059

Closed
Sk44rt opened this issue Oct 14, 2024 · 4 comments
Closed

Nav parameter for preventing focus loss by pressing ImGuiKey_Escape? #8059

Sk44rt opened this issue Oct 14, 2024 · 4 comments
Labels
nav keyboard/gamepad navigation

Comments

@Sk44rt
Copy link

Sk44rt commented Oct 14, 2024

Details:

My Issue/Question:

I need to disable the loss of navigation focus when the ImGuiKey_Escape button is pressed
I've been looking for a solution for the last four days. but didn't find anything
then I started looking at what lines in imgui.cpp could be commented out so that the focus would not be lost
and i found it!

imgui/imgui.cpp

Line 13347 in c4bc674

g.NavId = 0;

if g.NavId is not set to 0 then navigation focus remains

I think we can add bool parameter to ImGuiContext for preventing focus lost
something like NavPermanentFocus
and code:

if (!g.NavPermanentFocus)
    g.NavId = 0

and also, with this solution, focus can move to other items/windows/popups

@Sk44rt Sk44rt changed the title [FEATURE REQUEST] Nav parameter for preventing focus lost by pressing ImGuiKey_Escape [FEATURE REQUEST] Nav parameter for preventing focus loss by pressing ImGuiKey_Escape Oct 14, 2024
@ocornut ocornut changed the title [FEATURE REQUEST] Nav parameter for preventing focus loss by pressing ImGuiKey_Escape Nav parameter for preventing focus loss by pressing ImGuiKey_Escape? Oct 14, 2024
@ocornut ocornut added the nav keyboard/gamepad navigation label Oct 14, 2024
ocornut added a commit that referenced this issue Oct 14, 2024
@ocornut
Copy link
Owner

ocornut commented Oct 14, 2024

I thought there was an issue dedicated to this but I cannot find it..
However some related issues: #3200 #2048 #1074
They are related because I think we need a design that covers all those options, even if e.g. #3200 is asking for something that goes the opposite way of your request.

I do agree we need a solution.

@Sk44rt To gather some context, would you mind writing some more about your usage?
Can you confirm that you essentially want keyboard highlight to always be visible, aka essentially ImGui will be the only user of keyboard inputs in your application?

@Sk44rt
Copy link
Author

Sk44rt commented Oct 14, 2024

I thought there was an issue dedicated to this but I cannot find it.. However some related issues: #3200 #2048 #1074 They are related because I think we need a design that covers all those options, even if e.g. #3200 is asking for something that goes the opposite way of your request.

I do agree we need a solution.

@Sk44rt To gather some context, would you mind writing some more about your usage? Can you confirm that you essentially want keyboard highlight to always be visible, aka essentially ImGui will be the only user of keyboard inputs in your application?

Yup, ImGui is the only user of keyboard input

Some context
I'm trying to make a Kodi-like application specifically for usage on big screens (e.g. TV), so Keyboard/Gamepad will be the only way to navigate the UI (for which ImGui is used)
and losing focus is the only problem I've encountered

ocornut added a commit that referenced this issue Oct 18, 2024
ocornut added a commit that referenced this issue Oct 18, 2024
…(), ImGuiNavHighlightFlags to ImGuiNavRenderCursorFlags. (#1074, #2048, #7237, #8059, #1712, #7370, #787)

+ referenced in #8057, #3882, #3411, #2155, #3351, #4722, #1658, #4050.
ocornut added a commit that referenced this issue Oct 18, 2024
+ Further internal renaming for consistency.
ocornut added a commit that referenced this issue Oct 18, 2024
…ways. (#1074, #2048, #7237, #8059, #3200, #787)

Note: the NavCursorHideFrames addition is to support 88a3545 even though ConfigNavCursorVisibleAlways is set.
@ocornut
Copy link
Owner

ocornut commented Oct 18, 2024

I have added a few things related to those requests:

  • Nav: added io.ConfigNavCursorVisibleAuto and io.ConfigNavCursorVisibleAlways config options (ab9ce2a).
  • Nav: added SetNavCursorVisible() to override current state (634a7ed).

Technically I think the config options are sufficient for most people and would solve this, but SetNavCursorVisible() may also occasionally be useful (e.g. during startup to present both modes, while staying in Auto mode).

Other tangentially related options:

  • Nav: added io.ConfigNavEscapeClearFocusItem (7a56b41).
  • Nav: added io.ConfigNavEscapeClearFocusWindow (b001038).
  • And a couple of related fixes for all the above.

I'm closing this and other related issues as normally solved, but feel free to comment or open new issues if you have question or problem related to those.

(

Also note, if you have mods using internals, that those two fields have been renamed internally:

  • Terminology has been changed to call this the "nav cursor" more consistently.
  • bool NavDisableHighlight -> became bool NavCursorVisible (with opposite value).
  • bool NavDisableMouseHover -> became bool NavDisableMouseHover

)

@ocornut ocornut closed this as completed Oct 18, 2024
@MilesFan
Copy link

@ocornut

  • bool NavDisableMouseHover -> became bool NavDisableMouseHover

Is there any typo? I don't see the difference.
I am having problem in first trying ImRad, because NavDisableMouseHover is undefined.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
nav keyboard/gamepad navigation
Projects
None yet
Development

No branches or pull requests

3 participants