@@ -355,12 +355,14 @@ static void gui_window_draw_addresses_pane(Gui* gui, ImVec2 size) {
355355 MemorySearchResultSet * prev_set = (void * )-1 ;
356356 static int32_t dragging = -1 ;
357357 static size_t last_total = 0 ;
358+ static int32_t last_focused = 0 ;
358359 static int32_t last_selected = -1 ;
359360 static int32_t selected [UINT8_MAX ] = {-1 };
360361 static int32_t doubleclick_selected [UINT8_MAX ] = {-1 };
361362 if (last_total != batch -> total_results_count ) {
362363 dragging = -1 ;
363364 selected [0 ] = -1 ;
365+ last_focused = 0 ;
364366 last_selected = -1 ;
365367 last_total = batch -> total_results_count ;
366368 }
@@ -370,7 +372,6 @@ static void gui_window_draw_addresses_pane(Gui* gui, ImVec2 size) {
370372 if (ImGui_Shortcut (ImGuiKey_Escape , ImGuiInputFlags_None )) {
371373 selected [0 ] = -1 ;
372374 }
373- bool first_item = true;
374375 while (ImGuiListClipper_Step (& clipper )) {
375376 for (int32_t clip_i = clipper .DisplayStart ; clip_i < clipper .DisplayEnd ; clip_i ++ ) {
376377 ImGui_PushIDInt (clip_i );
@@ -478,8 +479,7 @@ static void gui_window_draw_addresses_pane(Gui* gui, ImVec2 size) {
478479 active_col .w *= 0.25 ;
479480 ImGui_PushStyleColorImVec4 (ImGuiCol_HeaderHovered , hover_col );
480481 ImGui_PushStyleColorImVec4 (ImGuiCol_HeaderActive , active_col );
481- if (first_item ) {
482- first_item = false;
482+ if (clip_i == last_focused ) {
483483 if (ImGui_Shortcut (
484484 ImGuiMod_Ctrl | ImGuiKey_A ,
485485 ImGuiInputFlags_RouteGlobal )) {
@@ -491,6 +491,9 @@ static void gui_window_draw_addresses_pane(Gui* gui, ImVec2 size) {
491491 "###hitbox" ,
492492 & is_selected ,
493493 ImGuiSelectableFlags_SpanAllColumns );
494+ if (ImGui_IsItemFocused ()) {
495+ last_focused = clip_i ;
496+ }
494497 if (ImGui_BeginPopupContextItem ()) {
495498 ImGui_PushFont (gui -> fonts .base );
496499 if (ImGui_Selectable (add_to_scratchpad )) {
@@ -935,12 +938,14 @@ static void gui_window_draw_scratchpad_pane(Gui* gui, ImVec2 size) {
935938 ImGui_GetFrameHeightWithSpacing ());
936939 static int32_t dragging = -1 ;
937940 static size_t last_total = 0 ;
941+ static int32_t last_focused = 0 ;
938942 static int32_t last_selected = -1 ;
939943 static int32_t selected [UINT8_MAX ] = {-1 };
940944 static int32_t doubleclick_selected [UINT8_MAX ] = {-1 };
941945 if (last_total != scratchpad -> items_count ) {
942946 dragging = -1 ;
943947 selected [0 ] = -1 ;
948+ last_focused = 0 ;
944949 last_selected = -1 ;
945950 last_total = scratchpad -> items_count ;
946951 }
@@ -950,7 +955,6 @@ static void gui_window_draw_scratchpad_pane(Gui* gui, ImVec2 size) {
950955 if (ImGui_Shortcut (ImGuiKey_Escape , ImGuiInputFlags_None )) {
951956 selected [0 ] = -1 ;
952957 }
953- bool first_item = true;
954958 while (ImGuiListClipper_Step (& clipper )) {
955959 for (int32_t clip_i = clipper .DisplayStart ;
956960 clip_i < clipper .DisplayEnd && (size_t )clip_i < scratchpad -> items_count ;
@@ -1068,8 +1072,7 @@ static void gui_window_draw_scratchpad_pane(Gui* gui, ImVec2 size) {
10681072 active_col .w *= 0.25 ;
10691073 ImGui_PushStyleColorImVec4 (ImGuiCol_HeaderHovered , hover_col );
10701074 ImGui_PushStyleColorImVec4 (ImGuiCol_HeaderActive , active_col );
1071- if (first_item ) {
1072- first_item = false;
1075+ if (clip_i == last_focused ) {
10731076 if (ImGui_Shortcut (
10741077 ImGuiMod_Ctrl | ImGuiKey_S ,
10751078 ImGuiInputFlags_RouteGlobal )) {
@@ -1082,6 +1085,9 @@ static void gui_window_draw_scratchpad_pane(Gui* gui, ImVec2 size) {
10821085 & is_selected ,
10831086 ImGuiSelectableFlags_SpanAllColumns ,
10841087 (ImVec2 ){0.0f , ImGui_GetFrameHeight ()});
1088+ if (ImGui_IsItemFocused ()) {
1089+ last_focused = clip_i ;
1090+ }
10851091 if (ImGui_BeginPopupContextItem ()) {
10861092 ImGui_PushFont (gui -> fonts .base );
10871093 if (ImGui_Selectable (remove_from_scratchpad )) {
0 commit comments