Tree Navigation keyboard actions addition request
Version/Branch of Dear ImGui:
1.92.0 WIP (19194) docking
Back-ends:
any
Compiler, OS:
any
Full config/build information:
No response
Details:
Currently tree keyboard navigation moves up/down correctly, and left/right on a non-leaf tree node opens and closes it correctly. Additions:
- Right arrow on an open non-leaf node should move selection down to first sub-node child node (else no nothing if it does not exist).
- Left arrow on a leaf node OR a closed non-leaf node should jump to the parent node.
This will be consistent with how File explorers work and tree views in most application.
Screenshots/Video:
No response
Minimal, Complete and Verifiable Example code:
Right arrow on an open non-leaf node should move selection down to first sub-node child node (else no nothing if it does not exist).
Hmm, sounds doable as a fallback if the nav request does not already have a candidate (e.g. if there is a Button on the right side of the TreeNode). As with the one below it would need to be a flag because it will incur a little bit of a extra bookkeeping cost.
Left arrow on a leaf node OR a closed non-leaf node should jump to the parent node.
FYI this is already supported using ImGuiTreeNodeFlags_NavLeftJumpsBackHere (maybe I should rename to ImGuiTreeNodeFlags_NavLeftJumpsBackToParent).
Thanks, did not even think it was an optional flag. Was expecting it to be default as well. That's going to be a pain with all our trees... :P But doable. It's the more important of the two actions. (at least for my muscle-memory)
It should be possible to consider a shared style/context way of enforcing some flags globally.
Amend: instead of behind a shared/global ImGuiTreeNodeFlags it may make sense to use a ItemFlags for this. Only a few tree flags will make sense to apply everywhere, and this was we can push/pop this as I don't thing applying EVERYWHERE it going to be desirable, some types of windows may want to opt-out.