From 7cee21122cc7388dbfbc95c3a204d94dc7bbb8a6 Mon Sep 17 00:00:00 2001 From: Musa Mahmood Date: Wed, 14 Oct 2026 20:05:25 +0100 Subject: [PATCH] [0.1.21] Right-click an OCR box in the image view to copy its text --- check_targets.jai | 2 +- first.jai | 2 +- src/app/ocr_ui.jai | 19 ++++++++++++++++++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/check_targets.jai b/check_targets.jai index 77191e8..b7e0b6d 100644 --- a/check_targets.jai +++ b/check_targets.jai @@ -47,7 +47,7 @@ APP_NAME :: "mcap"; APP_FOLDER_NAME :: "mcap"; GIT_BRANCH :: "check"; GIT_HASH :: "-"; -VERSION :: "0.1.20"; +VERSION :: "0.1.21"; BUILD_DATE :: "-"; DEBUG :: true; COMPILE_TESTS :: true; diff --git a/first.jai b/first.jai index b2d2f0a..299c42d 100644 --- a/first.jai +++ b/first.jai @@ -8,7 +8,7 @@ APP_NAME :: "mcap"; APP_FOLDER_NAME :: "mcap"; APP_BUNDLE_IDENTIFIER :: "com.example.mcap"; -VERSION :: "0.1.20"; +VERSION :: "0.1.21"; // Where everything goes: bin/, or bin-headless/ for builds made with no_crash_dialog, so automated // builds never write over the ones you run by hand. build_directory := "bin"; diff --git a/src/app/ocr_ui.jai b/src/app/ocr_ui.jai index fcd9215..225739b 100644 --- a/src/app/ocr_ui.jai +++ b/src/app/ocr_ui.jai @@ -53,6 +53,7 @@ ocr_ui: struct { show_boxes := true; match_cursor: s64 = -1; // which match Next and Previous last went to scroll_to_match: bool; + menu_text: string; // heap: the line right-clicked, for its menu's Copy window_open := false; toast_shown := false; @@ -943,6 +944,7 @@ ocr_ui_capture_overlay :: (index: s32, image_min: ImGui.ImVec2, zoom: float) { u plain := GetColorU32(.PlotHistogram, ifx searching then 0.35 else 1.0); matching := GetColorU32(.PlotLinesHovered); match_number := 0; + clicked: string; // the line right-clicked this frame; the last drawn, which is on top, where they overlap for section.lines { p0 := ImVec2.{image_min.x + it.x * scale_x, image_min.y + it.y * scale_y}; p1 := ImVec2.{p0.x + it.width * scale_x, p0.y + it.height * scale_y}; @@ -963,6 +965,21 @@ ocr_ui_capture_overlay :: (index: s32, image_min: ImGui.ImVec2, zoom: float) { u } else { draw.AddQuad(draw, q[0], q[1], q[2], q[3], plain, 1.5); } - if IsMouseHoveringRect(p0, p1) SetTooltip("% (%)", it.text, FF(it.confidence, 2)); + if IsMouseHoveringRect(p0, p1) { + SetTooltip("% (%)", it.text, FF(it.confidence, 2)); + if IsWindowHovered() && IsMouseClicked(.Right) clicked = it.text; + } + } + + // Right-click a box for its menu. The text is kept, since the reading may change while the menu is up. + MENU :: "##ocr_line_menu"; + if clicked { + free(ocr_ui.menu_text,, context.default_allocator); + ocr_ui.menu_text = copy_string(clicked,, context.default_allocator); + OpenPopup(MENU); + } + if BeginPopup(MENU) { + if MenuItem("Copy") clipboard_set_text(ocr_ui.menu_text); + EndPopup(); } }