imgui icon indicating copy to clipboard operation
imgui copied to clipboard

Tabbing/Navigation over all kind of items using the Tab key

Open JPGygax68 opened this issue 4 years ago • 6 comments

I cannot seem to navigate between my text field and my tree view (tree of TreeNode widgets) using the Tab key.

I can get to the text field (which is first child of my window) using Tab. When I click on my text field, I can tab out of it, but the focus does not go to my tree. When I click on any node of my tree, I can use the cursor keys to navigate and open/close nodes, but I cannot tab back to my text field.

The tree is wrapped into a BeginChild/EndChild group; the InputText widget is not.

Note: using cursor up/down, I can get a frame to display around either my text field or my tree; however, that seems to have no influence on the keyboard focus.

JPGygax68 avatar Apr 01 '20 20:04 JPGygax68

Hello Hans-Peter,

Essentially none of the things you are (justly) suggesting are presently implemented. The Tabbing system was implemented very early on (<1.00) and the keyboard/gamepad navigation system doesn't really uses it.

I had a large wip stash working on redesigning this but the feature set kinda grew (as I was working on an API to activate/focus item which requires solving more issues). I could perhaps try to get a simpler version of that in.

ocornut avatar Apr 01 '20 21:04 ocornut

Thanks Omar! Whatever you can do will be welcome. I quite understand that focus management is far from trivial.

JPGygax68 avatar Apr 02 '20 07:04 JPGygax68

Thanks for mentioning my issue. This is very serious blocker for me as my tool needs quick navigation using keyboard, that is quite a main requirement of my application. I was not even aware that is not currently possible when I started porting my code to ImGui... Anyway, good luck on getting this done!

slajerek avatar Jun 16 '21 18:06 slajerek

I was trying to design a simple modal with a textbox and an ok/cancel button and realized I couldn't tab from the textbox to the buttons. I pressed tab by second nature and didn't even consider it might not work. Though it's obvious in retrospect how annoying this could be to implement, it does seem fairly important for making polished UIs. Any workaround in the meantime?

dbechrd avatar Oct 26 '21 05:10 dbechrd

No workaround but I've put some very serious time last month in moving forward with tabbing and some aspect of navigation system. Quick recap.

  • Step 1 was #343, #4079, #2352
  • Then transitioned to working on tabbing across clipped text fields w/ scrolling #4449. Rewired a bunch of old tabbing stuff to the nav system and added better scrolling functions (done). New tabbing (for input/text fields still) almost works but..
  • Using a coarse clipper ala ImGuiListClipper makes wrapping on either end of a window difficult. I need to finish #3841 which I've already cleaned up and started working on test, then decided even after cleaning up the code was too complex so I'm rewriting it in a more flexible manner but had to find a way which wouldn't allocate every frame which is a basic rule I follow in the codebase. I'll try to get back to this soonish.
  • Once clipper is rewritten and can allow disjoint sections I'll find a way to make tabbing backward and forward wrapping to work with clipper and can close #4449
  • Once this is done we can look into rewiring tabbing to work on all elements (in fact much of the design work I've done for step 1 already had this in mind, along with stuff like #3949 and #1074) but aside from the technical work there's quite a good amount of design work to figure out how Tabbing can cohabit with directional navigation scheme, but for gamepad and also for keyboard, there are many situations with directional keyboard navigation is desirable/preferable so we'd need to design how that choice is done.

ocornut avatar Oct 26 '21 11:10 ocornut

  • [x] Another thing we will need take into account is Tabbing through InputTextMultiline() widgets. When they are configured to allow tab inputs, they cannot be tabbed out, and pressing ESC followed by Tab refocus the same item. This needs to be fixed as well.

EDIT Actually 66f0fb98 broke that, will fix soon.

ocornut avatar Nov 29 '21 11:11 ocornut

I have pushed the remaining glue to allow Tabbing to cycle through every items.

Note that "full" tabbing requires ImGuiConfigFlags_NavEnableKeyboard to be enabled. Without ImGuiConfigFlags_NavEnableKeyboard, tabbing will imitate old behavior which is to only cycle through text-inputable inputables.

I have also switched examples application to enable both ImGuiConfigFlags_NavEnableKeyboard and ImGuiConfigFlags_NavEnableGamepad by default now.

ocornut avatar Mar 10 '23 17:03 ocornut