Description
I want to create my object and then move them to the proper location.
Like i will have program functions that will create objects like buttons, which functions will be called from one main interface setup function.
In this case labels that are aligned to inputs should be move with the input when the second is repositioned.
Cause on initial creation of textarea you do not know the final position the textarea is at (X,Y)=(0,0) then the label is align to this outside of the screen cause the location is ALIGN_OUT_TOP. After repositioning the textarea the label does not follow even with lv_obj_invalidate(label) function.
What MCU/Processor/Board and compiler are you using?
esp32
What LVGL version are you using?
8.3 simulator
What do you want to achieve?
I want to be able to reposition items that are aligned in relationship with other items by repositioning the second ones.
What have you tried so far?
Have a function that creates label and place it above a textarea. This function is called and then i try to reallocate the textarea expecting label to be realocated by using the invalidate function but it does not work or the lv_obj_refr_pos
Code to reproduce
The code block(s) should be formatted like:
typedef struct{
lv_obj_t * ta;
lv_obj_t * kb;
lv_obj_t * lb;
}input_keyboard_obj;
typedef struct{
int32_t width;
int32_t height;
int32_t maxChars;
char* labelText;
char* placeholder;
bool pwdFlag;
bool oneLineFlag;
}textarea_t;
void main_view(){
textarea_t taConf={
.width=144,
.height=32,
.maxChars=10,
.labelText="The label Text",
.placeholder="The placeholder",
.pwdFlag=false,
.oneLineFlag=true
};
input_keyboard_obj tkl=create_text_area(taConf, LV_KEYBOARD_MODE_TEXT_UPPER);
lv_obj_set_pos(tkl.ta, 100, 70);
lv_obj_invalidate(tkl.lb);
}
input_keyboard_obj create_text_area(textarea_t taConf,lv_keyboard_mode_t kb_mode){
lv_obj_t *ta = lv_textarea_create(lv_scr_act());
lv_obj_set_size(ta, taConf.width, taConf.height);
lv_textarea_set_placeholder_text(ta, taConf.placeholder);
lv_textarea_set_password_mode(ta, taConf.pwdFlag);
lv_textarea_set_one_line(ta, taConf.oneLineFlag);
lv_textarea_set_max_length(ta, taConf.maxChars);
lv_obj_t *lb = lv_label_create(lv_scr_act());
lv_label_set_text(lb, taConf.labelText);
// lv_obj_set_style_bg_color(lb, lv_palette_main(LV_PALETTE_YELLOW), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_align_to(lb, ta, LV_ALIGN_OUT_TOP_LEFT, 0,0);
lv_obj_t *kb = create_keyboard(LV_KEYBOARD_MODE_TEXT_UPPER, ta);
lv_obj_add_event_cb(ta, textarea_event_handler, LV_EVENT_FOCUSED, kb);
lv_obj_add_event_cb(ta, textarea_event_handler, LV_EVENT_DEFOCUSED, kb);
input_keyboard_obj obj={
.kb=kb,
.ta=ta,
.lb=lb
};
return obj;
}
lv_obj_t * create_keyboard(lv_keyboard_mode_t kb_mode, lv_obj_t* textarea){
lv_obj_t *kb=lv_keyboard_create(lv_scr_act());
lv_keyboard_set_mode(kb, kb_mode);
lv_keyboard_set_textarea(kb, textarea);
return kb;
}