Get global coordinates of object


Trying to get global coordinates of object not based on parent only but base on main screen to automatically identify overlap of keyboard in order to make translation to move it out of the overlaping area. Program just crashes

What MCU/Processor/Board and compiler are you using?

esp32, simulator

What LVGL version are you using?


What do you want to achieve?

Non overlaping textareas from keyboard.

What have you tried so far?

I am trying to sum Y coordinate of object and all its parents to find the “global Y” coordinate of the object and stop the loop when i find that parent is the active screen or even NULL cause active screen has no parent. Then i can add the height of the object and crosscheck if it is bigger than the keyboards heigh which i know in general cause it is set to SCREEN_SIZE/4 .

The loop probably crashes on check if the next parent is NULL or lv_scr_act()

I am trying to print values to check if idea can give result.

Code to reproduce

I am back to this. I am trying to make a function that calculates y coord until i find lv_act_screen. But i crash the program

void str_shift_text_area(lv_obj_t * ta,lv_obj_t * kb){

	lv_coord_t taY = lv_obj_get_y(ta);

	lv_obj_t* obj=ta;

	while (obj!=lv_scr_act()){
		obj = lv_obj_get_parent(ta);
		taY += lv_obj_get_y(obj);

	lv_coord_t taH = lv_obj_get_height(ta);
	lv_coord_t kbY = lv_obj_get_y(kb);

	LV_LOG_USER("taX: %d",taY);
	LV_LOG_USER("taH: %d",taH);
	LV_LOG_USER("taH: %d",taY+taH);
	LV_LOG_USER("key: %d",kbY);

Do you really get a crash (an exception)?
Do you see any output of your LV_LOG_USER (…)?
It seems as you have an infinite loop (in your while (obj != lv_scr_act ())

no i do not get a crash really it is an infinite loop eithe by checking != lv_scr_act or != NULL so what is the correct check.

I placed and log out to and incremented index and it never stops

The problem is here:

obj = lv_obj_get_parent(ta);

omg now i see