-
-
Notifications
You must be signed in to change notification settings - Fork 10.7k
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 have scrolling working with selected items in a listbox ? #4242
Comments
Have you tried enabling keyboard navigation? There's currently no standalone function to force that scroll in the desirable way other than |
Actually |
Apologies: I had indeed skimmed through the first part of your initial message :(
I see. We have this feature in the However it's important to understand it only makes sense when the scopes are explicitly marked (otherwise there's no way to distinguish multiple selectable sets) + it needs a concept of restoring navigation id when reentering the scope. Let me investigate this. |
I have a pushed a few changes in the form of a It's a relatively simple change and can be used for single-selection. For multi-selection it's not usable as easily. // Auto-select when moved into
// - This will be more fully fleshed in the range-select branch
// - This is not exposed as it won't nicely work with some user side handling of shift/control
// - We cannot "unselect other selectables" with e.g. 'if (g.NavJustMovedToId != id) { selected = false; pressed = was_selected; }' for two reasons
// - (1) it would require focus scope to be set, need exposing PushFocusScope() or equivalent (e.g. BeginSelection() calling PushFocusScope())
// - (2) usage will fail with clipped items
// The multi-select API aim to fix those issues, e.g. may be replaced with a BeginSelection() API. |
Looks good to me 👍 |
Just tested it in my app ... works like a charm ! |
…ed (fix nav in one axis scrolling back and forth between axises when space is tight by just < ItemSpacing*2) (ocornut#3692, ocornut#2812, ocornut#4242, ocornut#2900) Amend 8f495e5
Could you please provide an example that works for this please? I have tried but no luck. If you could past a simple example that would be great please |
Hi @MacQuant ,
Hope it helps :) |
@rtoumazet |
…tered element that is not visible but could be would take the item's Y coordinate into account. Neither behavior were used in the codebase for this axis. Amend 27c58c3 (ocornut#5902, ocornut#2812, ocornut#4242, ocornut#2900) Signed-off-by: Neil Bickford <[email protected]>
Version/Branch of Dear ImGui:
Version: 1.83
Branch: master
Back-end/Renderer/Compiler/OS
Back-ends: imgui_impl_opengl3.cpp
Operating System: Windows
Hi.
I'm trying to have scrolling working with selected items in a listbox, using the keyboard.
If no element is highlighted in the listbox, moving from element to element using up and down arrow of the keyboard works fine, but as you can see in the video scrolling doesn't follow the selection :
When one element is highlighted, the scrolling works following the current highlighted element. Unfortunately, when the up or down key is kept down, the selected and highlighted element are getting desynchronized :
What is the best way to have the scrolling in phase with the selected element, instead of the highlighted one ?
Thank you !
Standalone, minimal, complete and verifiable example: (see #2261)
The text was updated successfully, but these errors were encountered: