improve widget_update_pointer_cursor

This commit is contained in:
lixianjing 2024-04-17 18:06:20 +08:00
parent 08a55a347d
commit 878a3333e5
2 changed files with 14 additions and 1 deletions

View File

@ -2,6 +2,7 @@
2024/04/17
* 修复fdb文档((感谢朝泽提供补丁)
* 修改widget\_update\_pointer\_cursor增加鼠标位置判断(感谢颖健提供补丁)
2024/04/15
* 增加文档 [如何使用 CMake 构建 AWTK 应用](how_to_use_cmake_to_build_awtk_app.md)

View File

@ -1325,10 +1325,22 @@ static const char* widget_get_pointer_cursor(widget_t* widget) {
}
ret_t widget_update_pointer_cursor(widget_t* widget) {
point_t p = {0, 0};
xy_t pointer_x = 0;
xy_t pointer_y = 0;
widget_t* wm = widget_get_window_manager(widget);
return_value_if_fail(wm != NULL, RET_BAD_PARAMS);
return window_manager_set_cursor(wm, widget_get_pointer_cursor(widget));
widget_to_global(widget, &p);
pointer_x = window_manager_get_pointer_x(wm);
pointer_y = window_manager_get_pointer_y(wm);
if (pointer_x >= p.x && pointer_x <= (p.x + widget->w) &&
pointer_y >= p.y && pointer_y <= (p.y + widget->h)) {
return window_manager_set_cursor(wm, widget_get_pointer_cursor(widget));
}
return RET_OK;
}
ret_t widget_dispatch(widget_t* widget, event_t* e) {