-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
How to disable Ctrl-tab menu ? #3255
Comments
Hello, Ctrl+Tab handling is currently enabled with keyboard navigation, aka setting the In theory we could add detailed flags to enable/disable subfeatures of keyboard navigation but I'd be interested in figuring out a more general way of dispatching inputs where you would somehow mark the ctrl+tab as handled and nav system won't handle that. Pragmatically it may be faster to expose those enable/disable flags sooner (I can think of situation where e.g. it would also be good to selectively enable/disable page up/page down). |
Thanks. Reading the comments in the main code, I did not figure out what was covered by the term "navigation" : now I understand better (I just found in the demo code the explanation that I missed ). Alas, the other features of navigation (esc, space, enter) were useful to me. But infact I am stupid : I just can steal this precise ctrl-tab event just before the call to ImGui::ProcessEvent... It should not be a problem, is it ? For your suggestions, indead, a way to handle these inputs separately, or maybe to reaffect theses naviguation keys would be great. By the way, what do you mean by "expose flags sooner" ? I read this expression a lot of time in the issues, but I do not understand what it means. |
You can't really steal or claim to handle inputs, that's my point. The only think you can do is to clear inputs manually before passing them to "Expose flags" = "add flags" I'm saying we could always add flags to select which feature to enable, but this is ultimately not the right solution (the right solution is to have a way to dispatch inputs, and it's going to be complex considering how dear imgui work), but the right solution being complex maybe it's ok to add the flags soon instead of waiting forever for the right solution.. |
Sorry, the ProcessEvent function is from the SFML backend, to send an event to ImGui from the event polling loop of my app : ImGui::SFML::ProcessEvent(event) . So, by stealing, I really mean not sending this particular ctrl-tab event to ImGui at all (thru the ImGuiIO object I suppose). I agree that it cannot be a solution for more complex keys that works only on some precise widgets.
:-D I was more interested in the meaning you were giving to "expose". For the perfect solution of "dispatching inputs", as ImGui is always working "one frame later" (or is not aware of its full state until the end of the frame due to its inherent immediate mode), I cannot figure out how you could dispatch inputs ahead. Imho, a few flags could definitely do the job. |
Moving followup to #4828 |
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. |
Can I ask where this is supposed to happen? When I try to call the first (global) example I hit this IM_ASSERT in IM_ASSERT(owner_id != ImGuiKeyOwner_Any && owner_id != ImGuiKeyOwner_None);
|
Yep I also crash when trying to redirect the routing to Line 9226 in d78e823
Also note that some of the API has changed:
#include "imgui_internal.h"
// REF:: https://github.com/ocornut/imgui/issues/5641 -> crashes with last master branch?
// called every frame, right?
ImGui::SetShortcutRouting(ImGuiMod_Ctrl | ImGuiKey_Tab, ImGuiInputFlags_RouteAlways, ImGuiKeyOwner_NoOwner);
ImGui::SetShortcutRouting(ImGuiMod_Ctrl | ImGuiMod_Shift | ImGuiKey_Tab, ImGuiInputFlags_RouteAlways, ImGuiKeyOwner_NoOwner); But editing the context navkeys as in #4828 works:#include "imgui_internal.h"
// REF:: https://github.com/ocornut/imgui/issues/4828
// called once! at some point will be moved to `ImGuiIO`, so there will be no need to include imgui_internal.h
ImGuiContext& g = *GImGui;
g.ConfigNavWindowingKeyNext = 0;
g.ConfigNavWindowingKeyPrev = 0; |
Sorry for my late answer. About specifically disabling CTRL+TAB ONLY g.ConfigNavWindowingKeyNext = 0; // replace the default which is `ImGuiMod_Ctrl | ImGuiKey_Tab`
g.ConfigNavWindowingKeyPrev = 0; // replace the default which is `ImGuiMod_Ctrl | ImGuiMod_Shift | ImGuiKey_Tab`. Full details there: #4828 (comment) About GENERIC shortcut routing (which can be leverage for everything, not just CTRL+Tab).
So effectively now you can do: ImGui::Shortcut(ImGuiMod_Ctrl | ImGuiKey_Tab, ImGuiInputFlags_RouteGlobal);
ImGui::Shortcut(ImGuiMod_Ctrl | ImGuiMod_Shift | ImGuiKey_Tab, ImGuiInputFlags_RouteGlobal); Some examples have been added in the demo: And there are more examples in a temporary "demo_input_owner_and_routing" branch: |
Strangely I have replied to Liam before seeing Diego answer, which says basically the same thing. Both answers complement each others and are going in the same direction. |
Version: Dear ImGui 1.77 WIP (17601)
Branch: master
Back-ends: SFML
Compiler: VS2019 c++
Operating System: win10x64
Hi,
How do I disable the Ctrl-tab menu ?
Because I would like to use ctrl-tab to manage my own window navigation logic, including other Non-Imgui windows.
The text was updated successfully, but these errors were encountered: