How to make an ImageButton selected (highlighted/focused) by default? #5867
Replies: 2 comments 4 replies
-
It sounds like you might be looking for if (ImGui::IsWindowAppearing())
ImGui::SetKeyboardFocusHere();
ImGui::ImageButton(/* ... */); Also for future reference, discussions should only be used for build/link/run/font issues only. Questions should be posted as issues. |
Beta Was this translation helpful? Give feedback.
-
My gut reaction reading this was that you may be mistaken, since Button() and ImageButton() use nearly identical code. // 3. Show another simple window.
if (show_another_window)
{
ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked)
ImGui::Text("Hello from another window!");
if (ImGui::Button("Close Me"))
show_another_window = false;
ImTextureID my_tex_id = io.Fonts->TexID;
if (ImGui::ImageButton("blah", my_tex_id, ImVec2(50, 50)))
show_another_window = false;
ImGui::SetItemDefaultFocus();
if (ImGui::Button("Another button"))
show_another_window = false;
ImGui::End();
}
|
Beta Was this translation helpful? Give feedback.
-
I'm creating a UI for an embedded device. Most of the time it's expected that the user would use a game controller or keyboard to navigate the UI.
The UI contains several ImageButtons and a text area. When the program starts, I noticed that there's no widget highlighted, but pressing the arrow key once would highlight one of the buttons. What I want is to designate one button to receive the highlight upon program start. I see there's a
SetItemDefaultFocus()
call in the demo code. But it has no effect on the ImageButtons. It does work on normal Button.Is there a way to achieve this?
Beta Was this translation helpful? Give feedback.
All reactions