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();
|
style_pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
// The open window (stats, catalog or settings): one at a time, fixed in size above the taskbar, closed by its X or
|
// The open window (stats, catalog, settings or cheats): one at a time, fixed in size above the taskbar, closed by its
|
||||||
// escape, and holding the mouse while open.
|
// X, escape or a click off it, and holding the mouse while open.
|
||||||
void Ui::window_draw(Play& play, Settings& settings, ImVec2 screen)
|
void Ui::window_draw(Play& play, Settings& settings, ImVec2 screen)
|
||||||
{
|
{
|
||||||
if (play.text.isScene)
|
if (play.text.isScene)
|
||||||
@@ -973,7 +973,12 @@ void Ui::window_draw(Play& play, Settings& settings, ImVec2 screen)
|
|||||||
cheats_draw(play);
|
cheats_draw(play);
|
||||||
else
|
else
|
||||||
settings_draw(settings);
|
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;
|
isOpen = false;
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
|
|||||||
Reference in new issue
Block a user