2021-04-08 13:07:48 +02:00
|
|
|
#include "../../lv_examples.h"
|
2021-02-14 14:56:34 +01:00
|
|
|
#if LV_USE_MSGBOX && LV_BUILD_EXAMPLES
|
2021-02-08 09:53:03 +01:00
|
|
|
|
2021-04-14 15:31:54 +02:00
|
|
|
static void event_cb(lv_event_t * e)
|
2021-02-08 09:53:03 +01:00
|
|
|
{
|
2023-12-12 15:33:31 +01:00
|
|
|
lv_obj_t * btn = lv_event_get_target(e);
|
|
|
|
lv_obj_t * label = lv_obj_get_child(btn, 0);
|
2023-12-15 23:03:08 +08:00
|
|
|
LV_UNUSED(label);
|
2023-12-12 15:33:31 +01:00
|
|
|
LV_LOG_USER("Button %s clicked", lv_label_get_text(label));
|
2021-02-08 09:53:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void lv_example_msgbox_1(void)
|
|
|
|
{
|
2023-12-12 15:33:31 +01:00
|
|
|
lv_obj_t * mbox1 = lv_msgbox_create(NULL);
|
2021-02-08 09:53:03 +01:00
|
|
|
|
2023-12-12 15:33:31 +01:00
|
|
|
lv_msgbox_add_title(mbox1, "Hello");
|
|
|
|
|
|
|
|
lv_msgbox_add_text(mbox1, "This is a message box with two buttons.");
|
|
|
|
lv_msgbox_add_close_button(mbox1);
|
|
|
|
|
|
|
|
lv_obj_t * btn;
|
|
|
|
btn = lv_msgbox_add_footer_button(mbox1, "Apply");
|
|
|
|
lv_obj_add_event_cb(btn, event_cb, LV_EVENT_CLICKED, NULL);
|
|
|
|
btn = lv_msgbox_add_footer_button(mbox1, "Cancel");
|
|
|
|
lv_obj_add_event_cb(btn, event_cb, LV_EVENT_CLICKED, NULL);
|
|
|
|
return;
|
2021-02-08 09:53:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|