CaptureKeyboardFromApp() / CaptureMouseFromApp(): allow to enforce clearing the capture flag (#533) + demo + made code a little less messy

This commit is contained in:
ocornut
2016-03-03 00:09:41 +01:00
parent cf12bc7dea
commit d45044fe54
4 changed files with 25 additions and 18 deletions

View File

@ -1503,10 +1503,14 @@ void ImGui::ShowTestWindow(bool* p_opened)
ImGui::Text("WantCaptureKeyboard: %s", io.WantCaptureKeyboard ? "true" : "false");
ImGui::Text("WantTextInput: %s", io.WantTextInput ? "true" : "false");
ImGui::Button("Hover me\nto enforce\ninputs capture");
ImGui::Button("Hovering me sets the\nkeyboard capture flag");
if (ImGui::IsItemHovered())
ImGui::CaptureKeyboardFromApp();
ImGui::CaptureKeyboardFromApp(true);
ImGui::SameLine();
ImGui::Button("Holding me clears the\nthe keyboard capture flag");
if (ImGui::IsItemActive())
ImGui::CaptureKeyboardFromApp(false);
ImGui::TreePop();
}