From e59d71893b6a58f0571f291377f5df052b5b3703 Mon Sep 17 00:00:00 2001 From: Ryan Fleury Date: Mon, 13 May 2024 12:57:45 -0700 Subject: [PATCH] bugfix copying & other accidental event consumption issues with new ui events --- src/df/gfx/df_gfx.c | 7 ++++++- src/ui/ui_core.c | 10 ++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/df/gfx/df_gfx.c b/src/df/gfx/df_gfx.c index ee7acbba..1f6e8078 100644 --- a/src/df/gfx/df_gfx.c +++ b/src/df/gfx/df_gfx.c @@ -11609,6 +11609,7 @@ df_do_txt_controls(TXT_TextInfo *info, String8 data, U64 line_count_per_page, Tx { String8 text = txt_string_from_info_data_txt_rng(info, data, txt_rng(*cursor, *mark)); os_set_clipboard_text(text); + taken = 1; } //- rjf: consume @@ -11633,7 +11634,10 @@ df_do_txti_controls(TXTI_Handle handle, U64 line_count_per_page, TxtPt *cursor, { next = n->next; B32 taken = 0; - + if(n->v.kind != UI_EventKind_Navigate && n->v.kind != UI_EventKind_Edit) + { + continue; + } String8 line = txti_string_from_handle_line_num(scratch.arena, handle, cursor->line); UI_TxtOp single_line_op = ui_single_line_txt_op_from_event(scratch.arena, &n->v, line, *cursor, *mark); @@ -11787,6 +11791,7 @@ df_do_txti_controls(TXTI_Handle handle, U64 line_count_per_page, TxtPt *cursor, { String8 text = txti_string_from_handle_txt_rng(scratch.arena, handle, txt_rng(*cursor, *mark)); os_set_clipboard_text(text); + taken = 1; } //- rjf: consume diff --git a/src/ui/ui_core.c b/src/ui/ui_core.c index 9892f329..905591ec 100644 --- a/src/ui/ui_core.c +++ b/src/ui/ui_core.c @@ -1355,10 +1355,11 @@ ui_end_build(void) //- rjf: clipboard commits { - Temp scratch = scratch_begin(0, 0); UI_Box *box = ui_box_from_key(ui_state->clipboard_copy_key); - String8List strs = {0}; + if(!ui_box_is_nil(box)) { + Temp scratch = scratch_begin(0, 0); + String8List strs = {0}; UI_BoxRec rec = {0}; for(UI_Box *b = box; !ui_box_is_nil(b); rec = ui_box_rec_df_pre(b, box), b = rec.next) { @@ -1375,8 +1376,8 @@ ui_end_build(void) String8 string = str8_list_join(scratch.arena, &strs, &join); os_set_clipboard_text(string); } + scratch_end(scratch); } - scratch_end(scratch); } //- rjf: hovering possibly-truncated drawn text -> store text @@ -2568,7 +2569,8 @@ ui_signal_from_box(UI_Box *box) //- rjf: focus is hot & copy event -> remember to copy this box tree's text content if(is_focus_hot && - evt->flags & UI_EventFlag_Copy) + evt->flags & UI_EventFlag_Copy && + !ui_key_match(ui_key_zero(), box->key)) { ui_state->clipboard_copy_key = box->key; taken = 1;