-
-
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
ImGui::SetKeyboardFocusHere doesn't highlight selected item #7370
Comments
The nav highlight is intentionally hidden when the mouse is used since the highlight is only intended only for keyboard and gamepad navigation, so you're fighting against the internal design of the nav system. It would be helpful to know exactly what you're trying to accomplish UI-wise from a user perspective as this feels very XY problem. Are you wanting the nav highlight to always be visible when the user interacts with all items or just for these selectables? If the latter, why? And could the built-in selectable highlighting suitable for your use-case? As an aside, |
Hello, The goal I want to achieve is when I press the mouse left click button on an item or use the UP/DOWN keys, it is selected in TreeNodeEX. When I move through the navigation, the item is selected there all the time, so I thought that when I change the focus of the keyboard, the selection automatically appears. My code at the moment works like this: int main(int argc, char* argv[]) void Application::KeyHandlerCallback(GLFWwindow* window, s32 key, s32 scancode, s32 action, s32 mods)
} For each item in the tree, I check: bool Application::IsItemClicked(ImGuiMouseButton mouse_button) whether a button was pressed, or an up or down button was pressed, and whether we hovered the mouse over an item. The operation of the program looks like this using this code: |
I can make it work if I set the ImGuiNavHighlightFlags_AlwaysDraw flag that seems to be unused in the ImGui::RenderNavHighlight function. Changing RenderFrame, so it triggers g.NavId == id as well would also be nice to implement. I think it would be nice to set some flag that forces widgets to be rendered this way. In other guis it seems to be a thing. This way highlights for the currently focused item will be persistent between the mouse clicking and nagivation movement. Virtual TreeView Example: https://youtu.be/TgXnG67DGko |
I have added a few things related to those requests:
Technically I think the config options are sufficient for most people. Other tangentially related options:
Technically this # also pertain to use SetKeyboardFocusHere() and other functions which are still be redesigned/improved. I'm closing this and other related issues as normally solved, but feel free to comment or open new issues if you have question or problem related to those. ( Also note, if you have mods using internals, that those two fields have been renamed internally:
) |
Version/Branch of Dear ImGui:
Version 1.90.0, Branch: docking
Back-ends:
imgui_impl_glfw.cpp + imgui_impl_opengl2.cpp
Compiler, OS:
Windows 10
Full config/build information:
No response
Details:
Hello,
I am trying to make a programmable change of the focus of the keyboard on the item using SetKeyboardFocusHere();; I've noticed that the highlight is not applied while doing so. I would like to get a highlight on this item in the same way as when the down/up navigation keys are pressed. The object in this case does not lose the highlight when the mouse is moved away.
Example code:
Screenshots/Video:
Got:
Expected:
Minimal, Complete and Verifiable Example code:
No response
The text was updated successfully, but these errors were encountered: