Description
What MCU/Processor/Board and compiler are you using?
F1C100S
What LVGL version are you using?
V8.3.6
What do you want to achieve?
When I click switch then pop up MessageBox, MessageBox display Chinese, choose 确定 or 取消, so switch turn on or turn off.(“确定” in English is sure, “取消” in English is cancle.)
What have you tried so far?
See lvgl official sample and try to modify it, I think in MessageBox for 确定 or 取消 need set font, but I not see like this sample. I run below code that I provide, result is I see box in 确定 and 取消 position.
Code to reproduce
Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.
The code block(s) should be formatted like:
/*You code here*/
static void event_cb(lv_event_t* e)
{
lv_obj_t* obj = lv_event_get_current_target(e);
LV_LOG_USER("Button %s clicked", lv_msgbox_get_active_btn_text(obj));
}
void lv_example_msgbox_1(void)
{
//static const char* btns[] = { "Apply", "Close", "" };
static const char* btns[] = { "确定", "取消", "" };
//lv_obj_t* mbox1 = lv_msgbox_create(NULL, "Hello", "This is a message box with two buttons.", btns, true);
lv_obj_t* mbox1 = lv_msgbox_create(NULL, NULL, "This is a message box with two buttons.", btns, true);
lv_obj_add_event_cb(mbox1, event_cb, LV_EVENT_VALUE_CHANGED, NULL);
lv_obj_center(mbox1);
}
static void event_handler(lv_event_t* e)
{
lv_event_code_t code = lv_event_get_code(e);
lv_obj_t* obj = lv_event_get_target(e);
if (code == LV_EVENT_VALUE_CHANGED) {
LV_UNUSED(obj);
lv_example_msgbox_1();
}
}
Call function is below:
ui_Switch1 = lv_switch_create(ui_Screen1);
lv_obj_set_width(ui_Switch1, 100);
lv_obj_set_height(ui_Switch1, 42);
lv_obj_set_x(ui_Switch1, -329);
lv_obj_set_y(ui_Switch1, -192);
lv_obj_set_align(ui_Switch1, LV_ALIGN_CENTER);
lv_obj_add_event_cb(ui_Switch1, event_handler, LV_EVENT_ALL, NULL);
Screenshot and/or video
If possible, add screenshots and/or videos about the current state.