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

Change Ctrl+Tab combo #4828

Closed
caxapexac opened this issue Dec 25, 2021 · 12 comments
Closed

Change Ctrl+Tab combo #4828

caxapexac opened this issue Dec 25, 2021 · 12 comments
Labels
inputs nav keyboard/gamepad navigation web

Comments

@caxapexac
Copy link

caxapexac commented Dec 25, 2021

Based on #3255, can't reopen issue so I've created the new one:

Version/Branch of Dear ImGui:

Version: 1.86
Branch: docking

Back-end/Renderer/Compiler/OS

Back-ends: webGL
Compiler: em++
Operating System: V8

My Issue/Question:

Ctrl+tab changes tab in browser

Proof: https://stackoverflow.com/questions/56835762/how-to-disable-ctrltab-in-javascript
Proof: https://stackoverflow.com/questions/8195175/javascript-code-to-press-ctrltab

So I need to be able to change combo from Ctrl+Tab to something else
i.e. IntelliJ uses Shift+Shift for this
i.e. IDE's uses Shift+Space for intellisense so it shoud be conveniently too

@caxapexac
Copy link
Author

@ocornut sorry you've opened it too late >_<

@ocornut
Copy link
Owner

ocornut commented Dec 25, 2021

Are you talking about Ctrl-Tab and not Alt-tab ? Your description keeps going back and forth between both..
(Docking has nothing to do with this, editing this out the title)

@caxapexac caxapexac changed the title [docking] Change Atl+Tab combo [docking] Change Ctrl+Tab combo Dec 25, 2021
@ocornut ocornut changed the title [docking] Change Ctrl+Tab combo Change Atl+Tab combo Dec 25, 2021
@ocornut ocornut added nav keyboard/gamepad navigation web labels Dec 25, 2021
@caxapexac
Copy link
Author

I'm about Ctrl+tab
image
This one

@caxapexac caxapexac changed the title Change Atl+Tab combo Change Ctrl+Tab combo Dec 25, 2021
@caxapexac
Copy link
Author

Maybe leave Ctrl and add option to config to choose between default Tab and other keys? Or hardcode 2-keys combo, something like:

io.ConfigDockingShortcutFirstKey = Key::Ctrl;
io.ConfigDockingShortcutSecondKey = Key::Q;

If you wanna single-key tab opening then something like:

io.ConfigDockingShortcutFirstKey = Key::Shift;
io.ConfigDockingShortcutSecondKey = Key::Shift;

Or maybe use array for it...

(I know it lead to huge issue of #456 but anyway could be discussed (maybe temporary solution until shortcut api))

@IceMilkTeaAddict
Copy link

IceMilkTeaAddict commented Mar 10, 2022

imgui.cpp

const bool start_windowing_with_keyboard = allow_windowing && !g.NavWindowingTarget && io.KeyCtrl && IsKeyPressed(ImGuiKey_Home);

↑ change it

@keszegh
Copy link

keszegh commented May 20, 2022

perhaps this is a proper thread to ask.
is there any way to disable the ctrl+tab functionality without disabling keyboard input on sliders etc.?
i have set nonavfocus for each window, but still ctrl+tab makes the window list to popup (which is containing only 'main menu bar' in it). this is not good for me, especially as i used so far ctrl+tab for something else.

@rokups
Copy link
Contributor

rokups commented May 23, 2022

There is no way to disable this at the moment. It would also be better if you created a new issue. Answering new issues is no bother, scattering useful information in mostly unrelated issues does not help information discoverability later on.

@keszegh
Copy link

keszegh commented May 23, 2022

thanks @rokups . and next time i make a new thread, at least my issue is almost the same as of the thread title (or at least the solution to that would solve mine too up to some level).

@ocornut
Copy link
Owner

ocornut commented May 23, 2022

I think it's fine in the same issue since doing the earlier would likely allow the later.

Tho by the look of it, the later (disable) may be doable soon. I'll post when I have updates.

@ocornut ocornut added the inputs label May 23, 2022
@keszegh
Copy link

keszegh commented May 23, 2022

@ocornut , thanks, disabling would be great and enough for me.

@DubbleClick
Copy link

Wouldn't it be enough to check if keyboard/gamepad navigation is even enabled before showing the window?

imgui.cpp line 10857:

const bool start_windowing_with_gamepad = allow_windowing && !g.NavWindowingTarget &&
                                          IsNavInputTest(ImGuiNavInput_Menu, ImGuiNavReadMode_Pressed) **&&
                                          io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad**;
const bool start_windowing_with_keyboard = allow_windowing && !g.NavWindowingTarget &&
                                           io.KeyCtrl && IsKeyPressed(ImGuiKey_Tab) **&&
                                           io.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard**;

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

We now have a more unified chord/shortcut systems and a solution for this.

While having discussions with other people I was also asked about remapping and specifically for the CTRL+Tab system.
While generic remapping is too difficult to reasonably achieve without adding extra burden for both library and user code, I realized that CTRL+Tab shortcuts are specific for two reasons:

  • There is the web-browsing hooking issue you pointed out.
  • It is also the only shortcut which intentionally reacts even is no imgui window is focused (e.g. if game in background is focused, what we refer as "void" in dear imgui).

For this reason it is reasonable to allow remapping this shortcut and now that it is easier to do, I've added an experimental/internal way to do it.

// Note this is in the Dear ImGui context, NOT in ImGuiIO yet
g.ConfigNavWindowingKeyNext = ImGuiMod_Ctrl | ImGuiKey_Tab;
g.ConfigNavWindowingKeyPrev = ImGuiMod_Ctrl | ImGuiMod_Shift | ImGuiKey_Tab;

This works:

g.ConfigNavWindowingKeyNext = ImGuiMod_Shift | ImGuiKey_Space;
g.ConfigNavWindowingKeyPrev = 0;

If both are setup, it is currently required that they share a same modifier for "holding".
Because of the way CTRL+Shift+Tab work it is designed to iterate in a sequence before applying focus.
If you do this:

g.ConfigNavWindowingKeyNext = ImGuiKey_F11;
g.ConfigNavWindowingKeyPrev = ImGuiKey_F10;

The "prev" shortcut doesn't work correctly as it will cycle between two windows.
Fixing it would require a different mode of operation were e.g. the UI stays open until validating (with Enter) or after a timeout.
We can consider implementing this later, just as I would consider changing the default in Emscripten context.

Closing this for now but curious about your feedback and I expect to improve it once we have users.

@ocornut ocornut closed this as completed Nov 8, 2022
PathogenDavid added a commit to PathogenDavid/imgui_test_engine that referenced this issue Mar 21, 2023
Also adds test for ensuring Ctrl+Shift+Tab works in the typical case.
Functional test for ocornut/imgui#4828
PathogenDavid added a commit to PathogenDavid/imgui_test_engine that referenced this issue Mar 21, 2023
Also adds test for ensuring Ctrl+Shift+Tab works in the typical case.
Functional test for ocornut/imgui#4828
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 web
Projects
None yet
Development

No branches or pull requests

6 participants