if keyboard is not overlap edit, do not push window

This commit is contained in:
lixianjing 2020-10-11 09:08:32 +08:00
parent a9338e7e0d
commit 682c9b1802
2 changed files with 27 additions and 7 deletions

View File

@ -2,6 +2,7 @@
2020/10/11
* label 增加 line\_wrap 属性。
* 完善输入法。如果 keyboard 与 edit 没有重叠,不再上推窗口。
2020/10/10
* window\_manager\_back 支持 overlay 和 popup。

View File

@ -163,6 +163,21 @@ static ret_t input_method_default_on_keyboard_open(void* ctx, event_t* e) {
return RET_REMOVE;
}
static bool_t is_key_board_overlap_edit(widget_t* keyboard, widget_t* edit) {
point_t p = {0, 0};
widget_to_screen(edit, &p);
if (p.x > keyboard->x && p.x < (keyboard->x + keyboard->w)) {
return TRUE;
}
if (keyboard->x > p.x && keyboard->x < (p.x + edit->w)) {
return TRUE;
}
return FALSE;
}
static ret_t input_type_open_keyboard(input_method_t* im, const char* keyboard_name,
bool_t open_anim) {
value_t v;
@ -189,13 +204,17 @@ static ret_t input_type_open_keyboard(input_method_t* im, const char* keyboard_n
widget_on(im->keyboard, EVT_DESTROY, input_method_default_on_keyboard_destroy, im);
if ((p.y + widget->h) > im->keyboard->y) {
close_anim_hint = "vtranslate";
open_anim_hint = close_anim_hint;
im->win = win;
if (is_key_board_overlap_edit(widget, im->keyboard)) {
im->win_delta_y = win->y + win->h - im->keyboard->y;
close_anim_hint = "vtranslate";
} else {
im->win_delta_y = 0;
close_anim_hint = "popup";
}
open_anim_hint = close_anim_hint;
widget_on(im->keyboard, EVT_WINDOW_OPEN, on_push_window, im);
} else if (win->y + win->h < im->keyboard->y) {
} else if ((win->y + win->h) < im->keyboard->y) {
/*when new keyboard height is not eq old keyboard height*/
close_anim_hint = "vtranslate";
im->win_delta_y += win->y + win->h - im->keyboard->y;