Made IsWindowFocused() work outside of NewFrame()-EndFrame() and added comments about how ImGuiFocusedFlags_AnyWindow should NOT be used in place of io.WantCaptureMouse. (#2185)

This commit is contained in:
omar 2018-11-13 11:23:15 +01:00
parent 5b1394c5ac
commit 19b4fcdacb
2 changed files with 2 additions and 2 deletions

View File

@ -5642,11 +5642,11 @@ bool ImGui::IsWindowHovered(ImGuiHoveredFlags flags)
bool ImGui::IsWindowFocused(ImGuiFocusedFlags flags) bool ImGui::IsWindowFocused(ImGuiFocusedFlags flags)
{ {
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
IM_ASSERT(g.CurrentWindow); // Not inside a Begin()/End()
if (flags & ImGuiFocusedFlags_AnyWindow) if (flags & ImGuiFocusedFlags_AnyWindow)
return g.NavWindow != NULL; return g.NavWindow != NULL;
IM_ASSERT(g.CurrentWindow); // Not inside a Begin()/End()
switch (flags & (ImGuiFocusedFlags_RootWindow | ImGuiFocusedFlags_ChildWindows)) switch (flags & (ImGuiFocusedFlags_RootWindow | ImGuiFocusedFlags_ChildWindows))
{ {
case ImGuiFocusedFlags_RootWindow | ImGuiFocusedFlags_ChildWindows: case ImGuiFocusedFlags_RootWindow | ImGuiFocusedFlags_ChildWindows:

View File

@ -732,7 +732,7 @@ enum ImGuiFocusedFlags_
ImGuiFocusedFlags_None = 0, ImGuiFocusedFlags_None = 0,
ImGuiFocusedFlags_ChildWindows = 1 << 0, // IsWindowFocused(): Return true if any children of the window is focused ImGuiFocusedFlags_ChildWindows = 1 << 0, // IsWindowFocused(): Return true if any children of the window is focused
ImGuiFocusedFlags_RootWindow = 1 << 1, // IsWindowFocused(): Test from root window (top most parent of the current hierarchy) ImGuiFocusedFlags_RootWindow = 1 << 1, // IsWindowFocused(): Test from root window (top most parent of the current hierarchy)
ImGuiFocusedFlags_AnyWindow = 1 << 2, // IsWindowFocused(): Return true if any window is focused ImGuiFocusedFlags_AnyWindow = 1 << 2, // IsWindowFocused(): Return true if any window is focused. Important: If you are trying to tell how to dispatch your low-level inputs, do NOT use this. Use ImGui::GetIO().WantCaptureMouse instead.
ImGuiFocusedFlags_RootAndChildWindows = ImGuiFocusedFlags_RootWindow | ImGuiFocusedFlags_ChildWindows ImGuiFocusedFlags_RootAndChildWindows = ImGuiFocusedFlags_RootWindow | ImGuiFocusedFlags_ChildWindows
}; };