From 80657ebbd96935122aa5f51e8e03f1db8da7f90a Mon Sep 17 00:00:00 2001
From: silverweed <silverweed14@proton.me>
Date: Tue, 12 Nov 2024 14:40:53 +0100
Subject: [PATCH] fix input flags

---
 src/render.cpp | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/src/render.cpp b/src/render.cpp
index 15c64f7..7b2d2f4 100644
--- a/src/render.cpp
+++ b/src/render.cpp
@@ -303,7 +303,6 @@ void update_and_render(Arena *arena, App_State &app, f32 delta_time_ms)
 
       ImGui::TableNextColumn();
       const ImGuiColorEditFlags edit_flags =  ImGuiColorEditFlags_NoInputs|ImGuiColorEditFlags_NoLabel;
-      const ImGuiInputTextFlags input_flags = 0;//ImGuiInputTextFlags_EnterReturnsTrue; // FIXME
 
       // Unique sections: just display a button that jumps to the start of it and show their size
       for (u32 i = 0; i < Sec_COUNT; ++i) {
@@ -339,12 +338,18 @@ void update_and_render(Arena *arena, App_State &app, f32 delta_time_ms)
         const i64 step_fast_i64 = app.rndata.n_pages / 100;
         i64 page_to_go_to = app.viewer.latest_page_gone_to;
         ImGui::PushItemWidth(100.f);
-        if (ImGui::InputScalar("##page_viewed", ImGuiDataType_S64, &page_to_go_to, &step_i64, &step_fast_i64, "%u", input_flags))
+        if (ImGui::InputScalar("##page_viewed", ImGuiDataType_S64, &page_to_go_to, &step_i64, &step_fast_i64, "%u") && 
+            ImGui::IsItemDeactivatedAfterEdit())
+        {
           app.viewer.latest_page = viewer_jump_to_page(app, page_to_go_to);
+        }
         ImGui::PopItemWidth();
       }
       ImGui::SameLine();
-      String8 this_page_width = app.viewer.latest_page ? push_str8f(scratch.arena, " (this page: %s)", to_pretty_size(scratch.arena, app.viewer.latest_page->range.len).c()) : str8("");
+      String8 this_page_width = app.viewer.latest_page 
+                                ? push_str8f(scratch.arena, " (this page: %s)", 
+                                             to_pretty_size(scratch.arena, app.viewer.latest_page->range.len).c()) 
+                                : str8("");
       ImGui::Text("%s%s", to_pretty_size(scratch.arena, app.rndata.tot_page_comp_size).c(), this_page_width.c());
 
       ImGui::ColorEdit3("_Checksum", app.viewer.col_checksum, edit_flags);
@@ -360,8 +365,11 @@ void update_and_render(Arena *arena, App_State &app, f32 delta_time_ms)
       {
         i64 page_list_to_go_to = app.viewer.latest_page_list_gone_to;
         ImGui::PushItemWidth(80.f);
-        if (ImGui::InputScalar("##page_list_viewed", ImGuiDataType_S64, &page_list_to_go_to, &step_i64, nullptr, "%u", input_flags))
+        if (ImGui::InputScalar("##page_list_viewed", ImGuiDataType_S64, &page_list_to_go_to, &step_i64, nullptr, "%u") 
+            && ImGui::IsItemDeactivatedAfterEdit())
+        {
           viewer_jump_to_page_list(app, page_list_to_go_to);
+        }
         ImGui::PopItemWidth();
       }
       ImGui::SameLine(); 
@@ -388,7 +396,9 @@ void update_and_render(Arena *arena, App_State &app, f32 delta_time_ms)
         const i64 step_fast_i64 = app.rndata.n_clusters / 100;
         i64 cluster_to_highlight = app.viewer.highlighted_cluster;
         ImGui::PushItemWidth(100.f);
-        if (ImGui::InputScalar("##highlighted_cluster", ImGuiDataType_S64, &cluster_to_highlight, &step_i64, &step_fast_i64, "%u", input_flags)) {
+        if (ImGui::InputScalar("##highlighted_cluster", ImGuiDataType_S64, &cluster_to_highlight, &step_i64, &step_fast_i64, "%u") &&
+            ImGui::IsItemDeactivatedAfterEdit())
+        {
           viewer_jump_to_cluster(app, cluster_to_highlight);
         }
         ImGui::PopItemWidth();