I’m a little bit confused about how canvas is handling events.
To implement a touch panel calibration function I like to cover the current screen with a canvas and draw some cross marks on it the user must hit for calibration.
But obviously the callbacks of the elements behind the canvas are triggered also if they are hit. Contrarily if I use an other object type (e.g. a container (
lv_obj_cont_create) or even the base object
lv_obj_create) the events are “consumed” by the this top most object as expected.
for example, this simple base object is consuming all events (objects below will not be triggered):
static lv_obj_t* canvas; canvas = lv_obj_create(lv_scr_act(), NULL); lv_obj_set_size(canvas, LV_HOR_RES, LV_VER_RES); lv_obj_align(canvas, NULL, LV_ALIGN_CENTER, 0, 0);
but not for canvas:
static lv_obj_t* canvas; static lv_color_t cbuf[LV_CANVAS_BUF_SIZE_TRUE_COLOR(LV_HOR_RES_MAX, LV_VER_RES_MAX)]; canvas = lv_canvas_create(lv_scr_act(), NULL); lv_obj_set_size(canvas, LV_HOR_RES_MAX, LV_VER_RES_MAX); lv_canvas_set_buffer(canvas, cbuf, LV_HOR_RES, LV_VER_RES, LV_IMG_CF_TRUE_COLOR); lv_obj_align(canvas, NULL, LV_ALIGN_CENTER, 0, 0); lv_canvas_fill_bg(canvas, LV_COLOR_GREEN, LV_OPA_COVER);
Bug or feature ?