Description
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?
8.3
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);
}