mirror of
https://github.com/zlgopen/awtk.git
synced 2025-05-08 19:44:45 +08:00
improve text edit
This commit is contained in:
parent
6ac7f75c26
commit
629013da1e
@ -792,7 +792,7 @@ SDL_SendKeyboardText(const char *text)
|
||||
int posted;
|
||||
|
||||
/* Don't post text events for unprintable characters */
|
||||
if ((unsigned char)*text < ' ' || *text == 127) {
|
||||
if ((unsigned char)*text < ' ' && *text != 8) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
2025/03/19
|
||||
* 修复在大分辨率下窗口动画有可能出现回弹的情况(感谢智明提供补丁)
|
||||
* 修复edit在 ipv4,date,time模式下光标位置异常的问题(感谢泽武提供补丁)
|
||||
* ext_edit_paste函数添加识别单个退格符与删除符,解决开启输入法智能标点时,在中文模式下输入数字加符号出现没有删除中文符号的问题(感谢泽武提供补丁)
|
||||
|
||||
2025/03/17
|
||||
|
@ -1874,6 +1874,15 @@ ret_t text_edit_key_down(text_edit_t* text_edit, key_event_t* evt) {
|
||||
break;
|
||||
}
|
||||
case TK_KEY_BACKSPACE: {
|
||||
#if defined(WITH_SDL)
|
||||
#if defined(MOBILE_APP)
|
||||
return RET_OK;
|
||||
#else
|
||||
if (system_info()->app_type == APP_DESKTOP) {
|
||||
return RET_OK;
|
||||
}
|
||||
#endif /*MOBILE_APP*/
|
||||
#endif /*WITH_SDL*/
|
||||
key = STB_TEXTEDIT_K_BACKSPACE;
|
||||
break;
|
||||
}
|
||||
@ -2073,6 +2082,30 @@ ret_t text_edit_paste(text_edit_t* text_edit, const wchar_t* str, uint32_t size)
|
||||
DECL_IMPL(text_edit);
|
||||
return_value_if_fail(text_edit != NULL && str != NULL, RET_BAD_PARAMS);
|
||||
|
||||
if (size == 1) {
|
||||
uint32_t key = 0;
|
||||
char text[4] = {0};
|
||||
delete_type_t delete_type;
|
||||
tk_utf8_from_utf16(str, text, 4);
|
||||
if (tk_strlen(text) == 1 && *text == 8) {
|
||||
key = STB_TEXTEDIT_K_BACKSPACE;
|
||||
delete_type = DELETE_BY_KEY_BACKSPACE;
|
||||
} else if (tk_strlen(text) == 1 && *text == 127) {
|
||||
key = STB_TEXTEDIT_K_DELETE;
|
||||
delete_type = DELETE_BY_KEY_DELETE;
|
||||
}
|
||||
if (key != 0) {
|
||||
if (impl->on_text_will_delete &&
|
||||
impl->on_text_will_delete(impl->on_text_will_delete_ctx, delete_type) == RET_STOP) {
|
||||
return RET_OK;
|
||||
}
|
||||
stb_textedit_key(text_edit, &(impl->state), key);
|
||||
text_edit_layout(text_edit);
|
||||
text_edit_update_input_rect(text_edit);
|
||||
return RET_OK;
|
||||
}
|
||||
}
|
||||
|
||||
if (impl->on_text_will_delete) {
|
||||
if (impl->on_text_will_delete(impl->on_text_will_delete_ctx, DELETE_BY_INPUT) == RET_STOP) {
|
||||
return RET_STOP;
|
||||
|
Loading…
x
Reference in New Issue
Block a user