Close taskbar windows on clicking off them
This commit is contained in:
1 parent
7dbb4cc154
commit
e0e43d9285
1 file changed
+8
-3
+8
-3
@@ -946,8 +946,8 @@ void Ui::catalog_draw(Play& play)
|
||||
style_pop();
|
||||
}
|
||||
|
||||
// The open window (stats, catalog or settings): one at a time, fixed in size above the taskbar, closed by its X or
|
||||
// escape, and holding the mouse while open.
|
||||
// The open window (stats, catalog, settings or cheats): one at a time, fixed in size above the taskbar, closed by its
|
||||
// X, escape or a click off it, and holding the mouse while open.
|
||||
void Ui::window_draw(Play& play, Settings& settings, ImVec2 screen)
|
||||
{
|
||||
if (play.text.isScene)
|
||||
@@ -973,7 +973,12 @@ void Ui::window_draw(Play& play, Settings& settings, ImVec2 screen)
|
||||
cheats_draw(play);
|
||||
else
|
||||
settings_draw(settings);
|
||||
if (ImGui::IsKeyPressed(ImGuiKey_Escape))
|
||||
ImVec2 min = ImGui::GetWindowPos();
|
||||
ImVec2 max = {min.x + ImGui::GetWindowWidth(), min.y + ImGui::GetWindowHeight()};
|
||||
bool isFocused = ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows | ImGuiFocusedFlags_NoPopupHierarchy);
|
||||
bool isClickedOff =
|
||||
isFocused && ImGui::IsMouseClicked(ImGuiMouseButton_Left) && !ImGui::IsMouseHoveringRect(min, max, false);
|
||||
if (ImGui::IsKeyPressed(ImGuiKey_Escape) || isClickedOff)
|
||||
{
|
||||
isOpen = false;
|
||||
ImGui::CloseCurrentPopup();
|
||||
|
||||
Reference in new issue
Block a user