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

How to make tabbing between InputText wrap the whole window, instead of only visible screen #4449

Closed
JJCUBER opened this issue Aug 20, 2021 · 4 comments
Labels
nav keyboard/gamepad navigation scrolling
Milestone

Comments

@JJCUBER
Copy link
Contributor

JJCUBER commented Aug 20, 2021

Version/Branch of Dear ImGui:

Version: 1.84 (WIP) - f99fe72
Branch: master

Back-end/Renderer/Compiler/OS

Back-ends: imgui_impl_sdl.cpp + imgui_impl_opengl3.cpp (using GLEW)

My Issue/Question:

I have spent a couple days trying to get tabbing between InputTexts working, without only wrapping around the visual screen area. I have looked through the demo, along with many github issues, but every issue that I find isn't related to my issue, or is very old and not really applicable.

To further elaborate on what I mean, when you have multiple InputTexts, with some of them scrolled offscreen, tabbing will loop around and focus on only the ones visible to the user. What I am trying to accomplish is having it wrap around all of the InputTexts in the current window, whilst scrolling to whichever one it activates. I have accomplished scrolling to the input text currently activated by doing this:

        if (GetCurrentContext()->LastItemData.StatusFlags & ImGuiItemStatusFlags_FocusedByTabbing)
            SetScrollHereY();

However, this does not solve anything when trying to tab from the bottom back to the very top, along with shift-tabbing from the top to the very bottom (or if two or more of the text fields aren't simultaneously visible at any given time).

I have also tried to partially override this "wrapping" by using a combination of ImGui::IsKeyPressedMap(ImGuiKey_Tab), ImGui::PushAllowKeyboardFocus(...), and ImGui::SetKeyboardFocusHere(), but have found it quite difficult to interface this properly with how InputTexts work, due to how much it does/handles.

Is there any way to do what I am asking for? If not, has anyone already made a custom solution to this? Any help in guiding me in the right direction would be greatly appreciated!

@JJCUBER JJCUBER changed the title How to make tabbing between InputFields wrap the whole window, instead of only visible screen How to make tabbing between InputTexts wrap the whole window, instead of only visible screen Aug 20, 2021
@ocornut ocornut added the nav keyboard/gamepad navigation label Aug 20, 2021
@ocornut
Copy link
Owner

ocornut commented Aug 20, 2021

I did some preliminary work on this in April, the problem is discussed here:
#4079 (comment)

I don’t have a simple answer to guide you through implementing it, if it was simple it would be fixed yet. Need a slight refactor of Nav process to sync scrolling to it. Lots of similar issues may be solved together after we move in that direction.

@ocornut ocornut changed the title How to make tabbing between InputTexts wrap the whole window, instead of only visible screen How to make tabbing between InputText wrap the whole window, instead of only visible screen Aug 20, 2021
@ocornut ocornut added this to the v1.85 milestone Sep 7, 2021
@ocornut
Copy link
Owner

ocornut commented Oct 6, 2021

Although not solved yet, note that as part of #343 and with 31d033c + 8f495e5, a good portion of the work to make that happen has been done already. Tabbing should be coming next.

@ocornut
Copy link
Owner

ocornut commented Oct 8, 2021

I almost got this working right but right using a ImGuiListClipper messes it up so I am investigating another way to solve this.
EDIT Done see #3841 (comment)

@ocornut ocornut modified the milestones: v1.85, v1.86 Oct 12, 2021
ocornut added a commit that referenced this issue Nov 4, 2021
…ling, using nav queries. (#4449)

Not using counter/modulo anymore and special provisions to handle tab wrapping with ImGuiListClipper. Wrapping may be done better as a next-frame forwarded request.
Also one extra step toward #3949 #3985
@ocornut
Copy link
Owner

ocornut commented Nov 4, 2021

This is now fixed by 1a7526d, tabbing now cycle through clipped INPUTABLE items and apply scrolling properly. This is the result of a long sequence of yak-shaving, scattered over past few months (among many other work of course).

The next step - and things have been reasonably prepared for that - it to allow cycling through any kind of items including non-inputable, aka #3092, and generalize the use of space/enter for activation. This tend to be a matter of seeing how the different features/idioms of navigation (other than directional arrows) are ready to be used more. (#787)

This will also lead us toward #3949, #1074, #3985

@ocornut ocornut closed this as completed Nov 4, 2021
actondev pushed a commit to actondev/imgui that referenced this issue Nov 26, 2021
…ling, using nav queries. (ocornut#4449)

Not using counter/modulo anymore and special provisions to handle tab wrapping with ImGuiListClipper. Wrapping may be done better as a next-frame forwarded request.
Also one extra step toward ocornut#3949 ocornut#3985
actondev pushed a commit to actondev/imgui that referenced this issue Nov 26, 2021
ocornut added a commit that referenced this issue Jun 10, 2022
…w when calling SetKeyboardFocusHere() and simultaneous changing window focus. (#4449)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
nav keyboard/gamepad navigation scrolling
Projects
None yet
Development

No branches or pull requests

2 participants