-
-
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
Focus loss when removing focused element #2129
Comments
Right. At the moment there's no fallback but we could/should try to a "in-place/neighbor" nav query when losing the current nav item. Depending what your button are for and if they are mutually exclusive, you may use the ### operator to have them use the same id:
Those two buttons will have the same identifier. |
The buttons are mutually exclusive. Is there a recommended way to preemptively assign focus to the next element if I detect that the "Remove" button is pressed? Or manually do the nearest neighbor search? |
So the solution pointed above would work.
Not yet with the public API. I have a stash with some of those implemented that I need to rework, but the general case for "focus this item" requires things like scrolling to keep something in view, and needs to be designed around the fact that items may be clipped (so queries needs to run pre-clipping). If you don't need this, you may include Linking to #1074. |
Sorry, I misspoke about the mutual exclusivity. I meant to say they are not mutually exclusive. I tried the SetNavId solution and that seems to be a reasonable workaround for now. Thanks! |
(Click "Preview" to turn any http URL into a clickable link)
Version/Branch of Dear ImGui:
master: c12da2a
Back-end file/Renderer/OS:
imgui_impl_dx12.cpp + imgui_impl_win32.cpp
OS: Windows
My Issue/Question:
I'm using the controller navigation. I have a user window that shows all the users in the game. It's possible to remove a user via a Remove button. When I remove the user, focus appears to be lost in the window. If I press the Left controller button, focus re-appears on the next button in the window. I'd like to make this happen by default when the button with focus is removed. In the example below, clicking Button 1 will make Button 1 disappear, and I'd like for focus to appear on Button 2.
Standalone, minimal, complete and verifiable example:
I tried some code like this in the handler of Button 1 with no success. But I'd also like avoid writing this kind of handling for removable items. This seems like something that should be handled in the framework itself.
The text was updated successfully, but these errors were encountered: