Browse Source

Demo: better demo for SetKeyboardFocusHere()

pull/1608/head
omar 7 years ago
parent
commit
518f02f4de
  1. 10
      imgui_demo.cpp

10
imgui_demo.cpp

@ -1753,6 +1753,16 @@ void ImGui::ShowTestWindow(bool* p_open)
ImGui::InputText("3 (tab skip)", buf, IM_ARRAYSIZE(buf));
if (ImGui::IsItemActive()) has_focus = 3;
ImGui::PopAllowKeyboardFocus();
// Use >= 0 parameter to SetKeyboardFocusHere() to focus an upcoming item
static float f3[3] = { 0.0f, 0.0f, 0.0f };
int focus_ahead = -1;
if (ImGui::Button("Focus on X")) focus_ahead = 0; ImGui::SameLine();
if (ImGui::Button("Focus on Y")) focus_ahead = 1; ImGui::SameLine();
if (ImGui::Button("Focus on Z")) focus_ahead = 2;
if (focus_ahead != -1) ImGui::SetKeyboardFocusHere(focus_ahead);
ImGui::SliderFloat3("Float3", &f3[0], 0.0f, 1.0f);
if (has_focus)
ImGui::Text("Item with focus: %d", has_focus);
else

Loading…
Cancel
Save