From 4846d52d0fa955c3b1b6aed478c1b7f49ce05066 Mon Sep 17 00:00:00 2001 From: lixianjing Date: Fri, 8 Nov 2024 11:28:53 +0800 Subject: [PATCH] improve text edit --- docs/changes.md | 1 + src/base/text_edit.c | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/changes.md b/docs/changes.md index ea1568a58..88fbe4721 100644 --- a/docs/changes.md +++ b/docs/changes.md @@ -2,6 +2,7 @@ 2024/11/08 * 去除克隆combo_box时不必要的打印信息(感谢雨欣提供补丁) + * 修复edit在一些情况下没有layout的问题(感谢泽武提供补丁) 2024/11/07 * 修复locale_infos_unref接口释放info对象无法清除assets_manager上的野指针导致崩溃的问题(感谢雨欣提供补丁) diff --git a/src/base/text_edit.c b/src/base/text_edit.c index a3fafa162..7977a25f1 100644 --- a/src/base/text_edit.c +++ b/src/base/text_edit.c @@ -2115,8 +2115,12 @@ ret_t text_edit_set_cursor(text_edit_t* text_edit, uint32_t cursor) { if (impl->state.cursor != cursor) { impl->state.cursor = cursor; - text_edit_update_caret_pos(text_edit); - text_edit_update_input_rect(text_edit); + if (impl->single_line) { + text_edit_layout(text_edit); + } else { + text_edit_update_caret_pos(text_edit); + text_edit_update_input_rect(text_edit); + } } return RET_OK;