Fix possible data loss
This commit is contained in:
parent
72591390d6
commit
5ad0938b3e
|
@ -8,19 +8,25 @@ void ok_buttons_fragment(bool* p_open, auto ok, auto apply);
|
||||||
// function bodies must be in the header because https://stackoverflow.com/a/999383
|
// function bodies must be in the header because https://stackoverflow.com/a/999383
|
||||||
|
|
||||||
void ok_buttons_fragment(bool* p_open, auto ok, auto apply) {
|
void ok_buttons_fragment(bool* p_open, auto ok, auto apply) {
|
||||||
|
bool action_done = false;
|
||||||
ImVec2 button_size(4 * ImGui::GetFontSize(), 0);
|
ImVec2 button_size(4 * ImGui::GetFontSize(), 0);
|
||||||
bool ctrl_s_pressed = ImGui::IsKeyPressed(ImGuiMod_Shortcut | ImGuiKey_S);
|
bool ctrl_s_pressed = ImGui::IsKeyPressed(ImGuiMod_Shortcut | ImGuiKey_S);
|
||||||
|
|
||||||
if (ImGui::Button("OK", button_size)) {
|
if (ImGui::Button("OK", button_size) && !action_done) {
|
||||||
ok();
|
ok();
|
||||||
*p_open = false;
|
*p_open = false;
|
||||||
|
action_done = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if (ImGui::Button("Cancel", button_size)) {
|
if (ImGui::Button("Cancel", button_size) && !action_done) {
|
||||||
*p_open = false;
|
*p_open = false;
|
||||||
|
action_done = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if (ImGui::Button("Apply", button_size) || ctrl_s_pressed) {
|
if ((ImGui::Button("Apply", button_size) || ctrl_s_pressed) && !action_done) {
|
||||||
apply();
|
apply();
|
||||||
|
action_done = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue