From 428334d33598f02257eb84b4e24bc273308440e1 Mon Sep 17 00:00:00 2001 From: Guillaume Chereau Date: Mon, 21 Oct 2024 14:29:25 +0800 Subject: [PATCH] Save settings when we change shortcuts Since I removed the save button, need to make sure we save each time something changes. --- src/gui.cpp | 10 +++++++++- src/gui/settings.c | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/gui.cpp b/src/gui.cpp index eb85bde5..3c315f12 100644 --- a/src/gui.cpp +++ b/src/gui.cpp @@ -968,6 +968,10 @@ static bool slider_float(float *v, float minv, float maxv, const char *format) static void update_activation_state(void) { int i; + + gui->item_activated = false; + gui->item_deactivated = false; + if (ImGui::IsItemActivated()) { gui->item_activated = true; for (i = 0; i < gui->groups_count; i++) { @@ -1468,7 +1472,11 @@ bool gui_button_right(const char *label, int icon) bool gui_input_text(const char *label, char *txt, int size) { - return ImGui::InputText(label, txt, size); + bool ret; + ret = ImGui::InputText(label, txt, size); + update_activation_state(); + return ret; + } bool gui_input_text_multiline(const char *label, char *buf, int size, diff --git a/src/gui/settings.c b/src/gui/settings.c index b0ba33ef..09c174eb 100644 --- a/src/gui/settings.c +++ b/src/gui/settings.c @@ -34,6 +34,7 @@ static int shortcut_callback(action_t *action, void *user) gui_next_column(); // XXX: need to check if the inputs are valid! gui_input_text("", action->shortcut, sizeof(action->shortcut)); + if (gui_is_item_deactivated()) settings_save(); gui_next_column(); gui_pop_id(); return 0;