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

Disable CTRL+Tab switcher popup? #5641

Closed
invrainbow opened this issue Sep 4, 2022 · 5 comments
Closed

Disable CTRL+Tab switcher popup? #5641

invrainbow opened this issue Sep 4, 2022 · 5 comments
Labels
inputs nav keyboard/gamepad navigation

Comments

@invrainbow
Copy link

invrainbow commented Sep 4, 2022

I'm on commit 77637fd9.

I'm building an IDE-like program and relying heavily on docking to draw the main user interface. I have an "empty section" where I draw my own application. Before, when the user did not have any tab/window focused, I would assume they had the "empty section" focused, and handle Ctrl+Tab manually.

I'm not sure when this happened, but recently I upgraded to commit 77637fd9. Now when the user presses Ctrl+Tab, no matter where they are, this tab switcher popup thingy opens.

image

Questions in descending order of optimality:

  1. Can I just disable this popup completely?
  2. If not, can I have it only open when a tab is focused, and not globally?
  3. If not, can I exclude the main menu from the list?
  4. If not, how can I find the commit where this was introduced?

Thanks!

@PathogenDavid
Copy link
Contributor

PathogenDavid commented Sep 4, 2022

  1. Can I just disable this popup completely?
  2. If not, can I have it only open when a tab is focused, and not globally?

Currently you cannot without modifying Dear ImGui. Disabling completely is something Omar has stated would fall out of #4828

  1. If not, can I exclude the main menu from the list?

Pass ImGuiWindowFlags_NoNavFocus to ImGui::Begin.

  1. If not, how can I find the commit where this was introduced?

The feature its self has been there for ages, but previously it was tied to keyboard navigation. It was enabled by default in 8ce23b3 as a part of #4023.

@ocornut
Copy link
Owner

ocornut commented Sep 4, 2022 via email

@ocornut ocornut added nav keyboard/gamepad navigation inputs labels Sep 4, 2022
@ocornut
Copy link
Owner

ocornut commented Sep 4, 2022

The reason the main menu bar doesn't use ImGuiWindowFlags_NoNavFocus is because we don't have a mechanism to globally use ALT to move to that menu bar, therefore it is often the only way to access it with the keyboard. You may however write a copy of the BeginMainMenuBar() and add the flag if wanted.

@ocornut ocornut changed the title Disable tab switcher popup when using docking? Disable CTRL+Tab switcher popup? Sep 4, 2022
@invrainbow
Copy link
Author

invrainbow commented Sep 5, 2022

Thanks for all the info!

After digging through imgui.cpp I successfully disabled ctrl+tab by setting GImGui->NavWindowingTarget = NULL after ImGui::NewFrame() in my code (also nice because I don't have to modify imgui). Do you see any problems down the road with doing this?

ocornut added a commit that referenced this issue Nov 8, 2022
…2891, #3370, #4828, #5108, #5242, #5641)

- Added SetKeyOwner(), SetItemKeyOwner(), TestKeyOwner().
- Added new IsKeyXXX IsMouseXXX functions with ImGuID owner_id and flags.
- Obsoleted SetItemUsingMouseWheel(). (#2891)
- Removed IsKeyPresseedEx() which was a recent internal addition 2022-07-08 deemed to be temporary exactly for this.
- Added ImGuiButtonFlags_NoSetKeyOwner, ImGuiButtonFlags_NoTestKeyOwner
- Added ImGuiSelectableFlags_NoSetKeyOwner.
- Added ImGuiInputFlags_LockThisFrame, ImGuiInputFlags_LockUntilRelease for for SetKeyOwner(), SetItemKeyOwner().
- Added ImGuiInputFlags_CondXXX values for SetItemKeyOwner().
ocornut added a commit that referenced this issue Nov 8, 2022
@ocornut
Copy link
Owner

ocornut commented Nov 8, 2022

Pushed a few new features and you can now do:

#include "imgui_internal.h"

// Disable CTRL+Tab shortcuts (global): assign a "None" route to steal the route to our two shortcuts
ImGui::SetShortcutRouting(ImGuiMod_Ctrl | ImGuiKey_Tab, ImGuiKeyOwner_None);
ImGui::SetShortcutRouting(ImGuiMod_Ctrl | ImGuiMod_Shift | ImGuiKey_Tab, ImGuiKeyOwner_None);

or

// Disable CTRL+Tab shortcuts (if focused): assign a "None" route to steal the route to our two shortcuts, applies focus testing so will only apply if window is in focus chain
ImGui::SetShortcutRouting(ImGuiMod_Ctrl | ImGuiKey_Tab, ImGuiKeyOwner_None, ImGuiInputFlags_RouteFocused);
ImGui::SetShortcutRouting(ImGuiMod_Ctrl | ImGuiMod_Shift | ImGuiKey_Tab, ImGuiKeyOwner_None, ImGuiInputFlags_RouteFocused);

However, as per #4828 we made the exception to allow remapping CTRL+Tab windowing system. Therefore technically the right shortcut needs to be pulled:

if (g.ConfigNavWindowingKeyNext)
    ImGui::SetShortcutRouting(g.ConfigNavWindowingKeyNext, ImGuiKeyOwner_None);
if (g.ConfigNavWindowingKeyPrev)
    ImGui::SetShortcutRouting(g.ConfigNavWindowingKeyPrev, ImGuiKeyOwner_None);

But this is only if you want to both allow remapping AND disabling of the shortcuts.

(cross posted to #3255 and #5641)

@ocornut ocornut closed this as completed Nov 8, 2022
kjblanchard pushed a commit to kjblanchard/imgui that referenced this issue May 5, 2023
…2637, ocornut#2620, ocornut#2891, ocornut#3370, ocornut#4828, ocornut#5108, ocornut#5242, ocornut#5641)

- Added SetKeyOwner(), SetItemKeyOwner(), TestKeyOwner().
- Added new IsKeyXXX IsMouseXXX functions with ImGuID owner_id and flags.
- Obsoleted SetItemUsingMouseWheel(). (ocornut#2891)
- Removed IsKeyPresseedEx() which was a recent internal addition 2022-07-08 deemed to be temporary exactly for this.
- Added ImGuiButtonFlags_NoSetKeyOwner, ImGuiButtonFlags_NoTestKeyOwner
- Added ImGuiSelectableFlags_NoSetKeyOwner.
- Added ImGuiInputFlags_LockThisFrame, ImGuiInputFlags_LockUntilRelease for for SetKeyOwner(), SetItemKeyOwner().
- Added ImGuiInputFlags_CondXXX values for SetItemKeyOwner().
ocornut added a commit that referenced this issue May 23, 2024
…wner_NoOwner: avoid confusion with non zero value, makes IsKeyPressed() calls using ImGuiKeyOwner_NoOwner more explicit.

Amend 4448d97 (#456, #2637, #2620, #2891, #3370, #4828, #5108, #5242, #5641)
ocornut added a commit that referenced this issue May 23, 2024
…versions of IsKeyPressed(), IsKeyChordPressed(), IsMouseClicked(). (#456)

For several reasons those changes makes sense. They are being made because making some of those API public.
Only past users of imgui_internal.h with the extra parameters will be affected.
Added asserts for valid flags in various functions to detect _some_ misuses, BUT NOT ALL.
Amend 4448d97 (#456, #2637, #2620, #2891, #3370, #4828, #5108, #5242, #5641)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
inputs nav keyboard/gamepad navigation
Projects
None yet
Development

No branches or pull requests

3 participants