mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-12-02 03:58:33 +08:00
if keyboard is not overlap edit, do not push window
This commit is contained in:
parent
a9338e7e0d
commit
682c9b1802
@ -2,7 +2,8 @@
|
||||
|
||||
2020/10/11
|
||||
* label 增加 line\_wrap 属性。
|
||||
|
||||
* 完善输入法。如果 keyboard 与 edit 没有重叠,不再上推窗口。
|
||||
|
||||
2020/10/10
|
||||
* window\_manager\_back 支持 overlay 和 popup。
|
||||
* 完善 API 注释(感谢兆坤提供补丁)。
|
||||
|
@ -146,7 +146,7 @@ static ret_t input_method_on_win_close(void* ctx, event_t* e) {
|
||||
widget_get_prop(im->keyboard, WIDGET_PROP_CLOSE_ANIM_HINT, &v);
|
||||
if (im->idle_close_id == TK_INVALID_ID) {
|
||||
window_close_force(im->keyboard);
|
||||
|
||||
|
||||
im->keyboard = NULL;
|
||||
im->widget = NULL;
|
||||
im->win = NULL;
|
||||
@ -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;
|
||||
im->win_delta_y = win->y + win->h - im->keyboard->y;
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user