Align to the left the text in the messagebox

Hi,
how can I align the text of a message box on the left instead of in the center?

Such as:

lv_label_set_align(label, LV_LABEL_ALIGN_LEFT);

Thanks
Walter

Please see p.110 of the documentation. I use LV ALIGN IN LEFT MID for what you want

There doesn’t seem to be an API for it. Are you interested in sending a pull request?

This should work, but I wrote it from the top of my head:

lv_mbox_ext_t *ext = (lv_mbox_ext_t *)lv_obj_get_ext_attr(mbox);
lv_label_set_align(ext->text, LV_LABEL_ALIGN_LEFT);

Are you reading the old, outdated 5.3 documentation? The new documentation on https://docs.littlevgl.com/ doesn’t use page numbers (from what I see).

im reading from the pdf. :smiley:

1 Like

Modifiying lv_mbox_set_text() worked for me:

void lv_mbox_set_text(lv_obj_t * mbox, const char * txt)
{
    LV_ASSERT_OBJ(mbox, LV_OBJX_NAME);
    LV_ASSERT_STR(txt);

    lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
    lv_label_set_text(ext->text, txt);
    lv_label_set_align(ext->text, LV_LABEL_ALIGN_LEFT);

    mbox_realign(mbox);
}

image

IMO a lv_mbox_get_label() function would be enough. Then the user can call lv_label_set_align() on the returned label. What do you think?

Hi,
thanks work fine.

Best regards
Walter