Can we get the parent type

how to know the type of a parent from lv_obj_get_parent.
if it is a container, button, page … etc?

I have a txt_area_callback that is assigned to more than one txt_area obj, each at a different page.
and when creating the keyboard I want to shrink its page and focus on the obj.
and both functions require the page pointer.
but some objs’ parents are the containers and others are window or tap
how could I get to know which is which?

Use this example (obj is your parent object). Object type names are at the top of their source file.

1 Like

many thanks,
actually, it didn’t work for me, the window is defined like this,
win = lv_win_create(lv_scr_act(), NULL);
and the txt_area like this,
lv_obj_t* ta_before = lv_textarea_create(win, NULL);
and yet,
when I am using lv_obj_get_parent it doesn’t return the same pointer as win obj
and the lv_obj_get_type(obj, &buf); returns NULL for this pointer.
so I don’t know which pointer it returns or what is wrong with this.

the workaround was to make the win pointer global static,
and NULL it when closing the window.
and check for it in the keyboard handler.
and it worked fine.
hope you have time to investigate it.

Oh; that’s because the window moves any children you add to a page. I think using lv_obj_get_parent(lv_obj_get_parent(obj)) will give you the window.

1 Like

Many thanks :heart:

Just tested your word.
and there is an additional layer,
I don’t know but
lv_obj_get_parent(lv_obj_get_parent(ta)) doesn’t return the window pointer
and when using
lv_page_focus(lv_obj_get_parent(ta), ta, LV_ANIM_ON);
generate a Guru Meditation Error on esp32
lv_page_focus(lv_obj_get_parent(lv_obj_get_parent(ta)), ta, LV_ANIM_ON);
works fine.

as for the txt_area in a tap
it needed 3 levels of parenting to get the tap name.
it is ancestors names are
the first parent also it is a page type but it generates also Guru Meditation Error
the 3rd is one that works fine with page_focuse function

Thank you for the correction! I was combining that docs page with how I remembered it so I probably missed a layer.

1 Like

actually I don’t understand how it works.
the txt_area obj in the tap and the window has the same parenting scheme.
in spite of I created the textarea at a container in the tap.
the container isn’t the first parent.
“at the window i didn’t put a container” and yet they are the same
it really doesn’t make anysense.

and the page_focus function works with the container parent of the window and the obj parent of the tap
and any other parent generates an error.