Lv_keyboard changes size and position of parent object. Is there a way to avoid it?

Description

lv_keyboad changes size and position of parent object on lv_obj_set_width call, it does not matter if it is lv_page, lv_cont or lv_win.

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

lv_sim_eclipse_sdl

What LVGL version are you using?

7.0.0

What do you want to achieve?

Integrate lv_keyboard with custom mapping into a widget without resizing it.

What have you tried so far?

Created a custom lv_cont based widget with lv_label and lv_keyboard.

Code to reproduce

lv_terminal.zip (3.7 KB)
Usage: call lv_terminal() instead of lv_demo_widgets() in lv_sim_eclipse_sdl’s main function.

Screenshot and/or video

Without trying to set position:


After setting width:

Maybe it is a bug and it should be moved to another forum.

Is autofit disabled on the container? It may be enabled by default. https://docs.lvgl.io/latest/en/html/widgets/cont.html#autofit

I do not think it is related to autofit. Behaviour of lv_keyboard depends on parent object. When I do lv_keyboard_create(lv_scr_act(), NULL) everything is OK, it reports size LV_POS_HORxLV_POS_VER/2. But if I do lv_keyboard_create(cs, NULL) where cs is fullscreen lv_cont it has margins or padding on right and left edges. Changing autofit value does not help. Default fit value is (0,0,0,0).

Looks like a problem is a container’s padding style. This line fixes my problem and I still do not know if it creates new.

lv_obj_t * cs = lv_cont_create(par, copy);
...
lv_obj_set_style_local_pad_hor(cs, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 0);

Will it create problems?

If you don’t want any space between the edge of the container and the keyboard, then your solution is the correct one.