Important: unclear posts may not receive useful answers.
Before posting
- Get familiar with Markdown to format and structure your post
- Be sure to update lvgl from the latest version from the
master
branch.- Be sure you have checked the FAQ and read the relevant part of the documentation.
- If applicable use the Simulator to eliminate hardware related issues.
Delete this section if you read and applied the mentioned points.
Description
For pointer input devices like crown, which cannot focus like touch screens or mouse clicks, I am trying to automatically focus on the menu with multiple lists when entering the page. I am not sure if it is feasible.
What MCU/Processor/Board and compiler are you using?
BES2700BP
What LVGL version are you using?
LVGL 8.3.10
What do you want to achieve?
Assuming there are multiple lists on the display and one of them has focus, I want to query the coordinates of this focus. When calling the lv_indev_search_obj
function, pass in the parameters to achieve automatic focusing.
What have you tried so far?
Add a query function _lv_ll_obj_find
to find the focused object
Code to reproduce
Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.
The code block(s) should be formatted like:
Pass the coordinates of the focus object to act_point
/*If there is no last object then search*/
if(indev_obj_act == NULL) {
lv_point_t fouse_point;
lv_obj_t *fouse_obj = _lv_ll_obj_find();
if(fouse_obj) {
fouse_point.x = (fouse_obj->coords.x1 + fouse_obj->coords.x2) / 2;
fouse_point.y = (fouse_obj->coords.y1 + fouse_obj->coords.y2) / 2;
}
else {
fouse_point = proc->types.pointer.act_point;
}
if(indev_obj_act == NULL) indev_obj_act = lv_indev_search_obj(lv_disp_get_layer_sys(disp), &fouse_point);
if(indev_obj_act == NULL) indev_obj_act = lv_indev_search_obj(lv_disp_get_layer_top(disp),
&fouse_point);
if(indev_obj_act == NULL) indev_obj_act = lv_indev_search_obj(lv_disp_get_scr_act(disp),
&fouse_point);
new_obj_searched = true;
}
Searching for the focus object is currently causing a crash.
lv_obj_t * _lv_ll_obj_find(void)
{
lv_ll_t * ll_p = &LV_GC_ROOT(_lv_group_ll);
void * i;
void * i_next;
lv_obj_t *obj_find = NULL;
i = _lv_ll_get_head(ll_p);
i_next = NULL;
while(i != NULL) {
i_next = _lv_ll_get_next(ll_p, i);
lv_group_t *group = (lv_group_t *)i_next;
if (*(group->obj_focus)) {
obj_find = *(group->obj_focus);
break;
}
i = i_next;
}
return obj_find;
}
Screenshot and/or video
If possible, add screenshots and/or videos about the current state.