diff --git a/src/base/widget.c b/src/base/widget.c index 97dc8618b..e10b08f03 100644 --- a/src/base/widget.c +++ b/src/base/widget.c @@ -1240,8 +1240,7 @@ ret_t widget_on_pointer_down(widget_t* widget, pointer_event_t* e) { target = widget_find_target(widget, e->x, e->y); if (target != NULL && target->enable) { - const char* type = widget_get_type(target); - if (!tk_str_eq(type, WIDGET_TYPE_KEYBOARD)) { + if (!(target->vt->is_keyboard)) { if (!target->focused) { event_t focus = event_init(EVT_FOCUS, target); if (widget->key_target) { diff --git a/src/base/widget.h b/src/base/widget.h index 262bae855..41ab2ca42 100644 --- a/src/base/widget.h +++ b/src/base/widget.h @@ -86,6 +86,10 @@ typedef struct _widget_vtable_t { * 是否是设计窗口。 */ uint32_t is_designing_window : 1; + /** + * 是否是软键盘(点击软键盘不改变编辑器的焦点)。 + */ + uint32_t is_keyboard: 1; widget_create_t create; widget_get_prop_t get_prop; diff --git a/src/ext_widgets/keyboard/keyboard.c b/src/ext_widgets/keyboard/keyboard.c index b5a2f061e..a736ff8ec 100644 --- a/src/ext_widgets/keyboard/keyboard.c +++ b/src/ext_widgets/keyboard/keyboard.c @@ -47,6 +47,7 @@ static ret_t keyboard_on_destroy(widget_t* widget) { static const widget_vtable_t s_keyboard_vtable = {.size = sizeof(keyboard_t), .type = WIDGET_TYPE_KEYBOARD, .is_window = TRUE, + .is_keyboard = TRUE, .clone_properties = s_keyboard_properties, .persistent_properties = s_keyboard_properties, .create = keyboard_create,