Skip to content

Commit

Permalink
Save settings when we change shortcuts
Browse files Browse the repository at this point in the history
Since I removed the save button, need to make sure we save each time
something changes.
  • Loading branch information
guillaumechereau committed Oct 21, 2024
1 parent ddcd356 commit 428334d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/gui/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 428334d

Please sign in to comment.