-
-
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
Keyboard navigation inconsistency depending on types of nodes in multiple columns #6344
Comments
This is an issue with the directional navigation scoring system, similar to #6003 and #1688 (also related to #2694). The issue is made apparent with item of varying heights and spacing. (It might also be exacerbated by the fact that both CollapsingHeader() and Selectable() have extruded padding, but that part alone we can easily fix by passing the non-padded nav-rect to |
@ocornut do you know of any work-around besides forcing all items to be the same type? |
The type of item doesn't matter, the issue here is due to their relative height. |
If you don't mind I would like to keep it open as it has been among my reference/test cases for a rework of some nav scoring logic. |
I'm happy to hear that the nav scoring is getting some attention. If you want me to try a patch, or send some code to reproduce the layout in #6003, I'd be glad to do so. |
The reason I closed it is because I tried with some test code I had locally, and the keyboard navigation felt more consistent. If you want to keep it open that's fine |
I have also recently run into this issue. I created a table containing one column of TreeNodes and another column of Buttons, and observed that pressing the up arrow on a TreeNode would send me to the Button on the previous row. Given the hint here about varying item heights (thanks!), I was able to work around it by using the equivalent of SmallButton. That both fixed the keyboard navigation, and fixed my line spacing (as the buttons originally forced the line spacing wider than it would be for TreeNodes alone), so it's a good solution for me. In case it's of interest, here's a bit of test code that repros the problem:
Switching the Buttons for SmallButtons works around the issue. |
Version/Branch of Dear ImGui:
Version: v1.89.5
Branch: master
Back-end/Renderer/Compiler/OS
Back-ends: imgui_impl_dx12.cpp + imgui_impl_win32.cpp
Compiler: VS2022
Operating System: Windows 10
My Issue/Question:
I am attempting to create a window that has a table with 2 columns, 1 row. Each column has multiple CollapsingHeader, TreeNode and Selectable within it. If all the objects are of the same type, navigation works as expected: down arrow moves a node down, right moves a column to the right, etc etc. But as soon as you begin mixing different node types, navigation breaks completely. Sometimes pressing down moves you a column to the right, sometimes pressing up moves you to the left. It's hard to predict. Unfortunately many of my users do not have mouses, so consistent keyboard navigation is a must.
Screenshots/Video
XXX (you can drag files here)
Standalone, minimal, complete and verifiable example:
ImGui::Begin("table test"); if( ImGui::BeginTable( "table1", 2 ) ) { ImGui::TableNextColumn(); ImGui::CollapsingHeader( "1" ); ImGui::CollapsingHeader( "2" ); ImGui::CollapsingHeader( "3" ); ImGui::CollapsingHeader( "4" ); ImGui::CollapsingHeader( "5" ); ImGui::TableNextColumn(); ImGui::CollapsingHeader( "6" ); ImGui::CollapsingHeader( "7" ); ImGui::CollapsingHeader( "8" ); ImGui::EndTable(); }
^works
ImGui::Begin( "table test 2" ); if( ImGui::BeginTable( "table1", 2 ) ) { ImGui::TableNextColumn(); ImGui::CollapsingHeader( "1" ); ImGui::Selectable( "s1" ); ImGui::CollapsingHeader( "2" ); ImGui::CollapsingHeader( "3" ); ImGui::CollapsingHeader( "4" ); ImGui::CollapsingHeader( "5" ); ImGui::TableNextColumn(); ImGui::CollapsingHeader( "6" ); ImGui::CollapsingHeader( "7" ); ImGui::Selectable( "s2" ); ImGui::CollapsingHeader( "8" ); ImGui::Selectable( "s3" ); ImGui::EndTable(); }
^broken
The text was updated successfully, but these errors were encountered: