From a2bd9b96998237d3edda30930c5eecab2b6bc475 Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Mon, 24 Feb 2025 01:12:31 +0000 Subject: [PATCH] X buttons to close popups --- CHANGELOG.md | 1 + src/gui/window.c | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0772670..099a1cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ### Added: - Drag click to select items in address list and scratchpad - Confirm dialog box when detaching process with an active search or addresses in scratchpad +- X buttons to close popups like clicking cancel ### Updated: - Use custom `thread_cancel()` implementation that is more portable and works with `-fexceptions` diff --git a/src/gui/window.c b/src/gui/window.c index a71b399..3232a87 100644 --- a/src/gui/window.c +++ b/src/gui/window.c @@ -43,9 +43,10 @@ static void gui_window_draw_attach_process_popup(Gui* gui) { (ImVec2){display.x / 2.0f, display.y / 2.0f}, ImGuiCond_Always, (ImVec2){0.5f, 0.5f}); + bool popup_still_open = true; if(ImGui_BeginPopupModal( attach_process, - NULL, + &popup_still_open, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize)) { static ProcessList* list = NULL; @@ -119,7 +120,7 @@ static void gui_window_draw_attach_process_popup(Gui* gui) { ImGui_EndDisabled(); ImGui_SameLine(); - if(ImGui_Button(cancel)) { + if(ImGui_Button(cancel) || !popup_still_open) { process_list_free(list); list = NULL; ImGui_CloseCurrentPopup(); @@ -135,9 +136,10 @@ static void gui_window_draw_detach_process_popup(Gui* gui) { (ImVec2){display.x / 2.0f, display.y / 2.0f}, ImGuiCond_Always, (ImVec2){0.5f, 0.5f}); + bool popup_still_open = true; if(ImGui_BeginPopupModal( detach_process, - NULL, + &popup_still_open, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize)) { ImGui_TextUnformatted("Are you sure you want to detach from the process?"); @@ -160,7 +162,7 @@ static void gui_window_draw_detach_process_popup(Gui* gui) { } ImGui_SameLine(); - if(ImGui_Button(cancel)) { + if(ImGui_Button(cancel) || !popup_still_open) { ImGui_CloseCurrentPopup(); }