refactor(event): add _cb postfix to lv_obj_add_event()

This commit is contained in:
Gabor Kiss-Vamosi 2023-11-28 15:36:51 +01:00
parent d7981cf55f
commit f0988b8cf8
179 changed files with 362 additions and 362 deletions

View File

@ -23,7 +23,7 @@
} while(0)
#define SPINBOX_EVENT_ATTACH(item) \
lv_obj_add_event(ui->ctrl_pad.tab.layout.spinbox_##item, ctrl_pad_spinbox_event_handler, LV_EVENT_VALUE_CHANGED, ui);
lv_obj_add_event_cb(ui->ctrl_pad.tab.layout.spinbox_##item, ctrl_pad_spinbox_event_handler, LV_EVENT_VALUE_CHANGED, ui);
/**********************
* TYPEDEFS
@ -64,7 +64,7 @@ void ctrl_pad_attach(view_t * ui)
SPINBOX_EVENT_ATTACH(pad_row);
SPINBOX_EVENT_ATTACH(flex_grow);
lv_obj_add_event(
lv_obj_add_event_cb(
ui->ctrl_pad.tab.flex.checkbox_scrl,
ctrl_pad_checkbox_event_handler,
LV_EVENT_VALUE_CHANGED,
@ -150,14 +150,14 @@ static void ctrl_pad_checkbox_event_handler(lv_event_t * e)
static void ctrl_pad_btn_event_attach(view_t * ui)
{
lv_obj_add_event(
lv_obj_add_event_cb(
ui->ctrl_pad.btn.add,
ctrl_pad_btn_add_event_handler,
LV_EVENT_CLICKED,
ui
);
lv_obj_add_event(
lv_obj_add_event_cb(
ui->ctrl_pad.btn.remove,
ctrl_pad_btn_remove_event_handler,
LV_EVENT_CLICKED,

View File

@ -41,11 +41,11 @@
#define FLEX_ALIGN_EVENT_ATTACH(item) \
do { \
lv_obj_add_event(ui->ctrl_pad.tab.align.ddlist_align_##item, \
flex_align_##item##_event_handler, \
LV_EVENT_VALUE_CHANGED, \
ui \
); \
lv_obj_add_event_cb(ui->ctrl_pad.tab.align.ddlist_align_##item, \
flex_align_##item##_event_handler, \
LV_EVENT_VALUE_CHANGED, \
ui \
); \
} while(0)
/**********************
@ -96,7 +96,7 @@ FLEX_ALIGN_EVENT_DEF(track)
void flex_loader_attach(view_t * ui)
{
lv_obj_add_event(
lv_obj_add_event_cb(
ui->ctrl_pad.tab.flex.ddlist_flow,
flex_flow_event_handler,
LV_EVENT_VALUE_CHANGED,

View File

@ -54,7 +54,7 @@ lv_obj_t * obj_child_node_create(lv_obj_t * par, view_t * ui)
lv_obj_add_flag(label, LV_OBJ_FLAG_IGNORE_LAYOUT | LV_OBJ_FLAG_FLOATING);
lv_obj_center(label);
lv_obj_add_event(obj, obj_child_node_event_handler, LV_EVENT_CLICKED, ui);
lv_obj_add_event_cb(obj, obj_child_node_event_handler, LV_EVENT_CLICKED, ui);
return obj;
}

View File

@ -216,8 +216,8 @@ static lv_obj_t * spinbox_ctrl_create(lv_obj_t * par, lv_style_prop_t prop, lv_o
lv_label_set_text(label, "+");
lv_obj_center(label);
lv_obj_add_event(btn_inc, btn_inc_event_handler, LV_EVENT_ALL, spinbox);
lv_obj_add_event(btn_dec, btn_dec_event_handler, LV_EVENT_ALL, spinbox);
lv_obj_add_event_cb(btn_inc, btn_inc_event_handler, LV_EVENT_ALL, spinbox);
lv_obj_add_event_cb(btn_dec, btn_dec_event_handler, LV_EVENT_ALL, spinbox);
return spinbox;
}

View File

@ -156,15 +156,15 @@ static void text_input_create(lv_obj_t * parent)
lv_obj_t * kb = lv_keyboard_create(lv_screen_active());
lv_obj_add_flag(kb, LV_OBJ_FLAG_HIDDEN);
lv_obj_add_event(ta1, ta_event_cb, LV_EVENT_ALL, kb);
lv_obj_add_event(ta2, ta_event_cb, LV_EVENT_ALL, kb);
lv_obj_add_event_cb(ta1, ta_event_cb, LV_EVENT_ALL, kb);
lv_obj_add_event_cb(ta2, ta_event_cb, LV_EVENT_ALL, kb);
}
static void msgbox_create(void)
{
static const char * buttons[] = {"Ok", "Cancel", ""};
lv_obj_t * mbox = lv_msgbox_create(NULL, "Hi", "Welcome to the keyboard and encoder demo", buttons, false);
lv_obj_add_event(mbox, msgbox_event_cb, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(mbox, msgbox_event_cb, LV_EVENT_ALL, NULL);
lv_group_focus_obj(lv_msgbox_get_buttons(mbox));
lv_obj_add_state(lv_msgbox_get_buttons(mbox), LV_STATE_FOCUS_KEY);
lv_group_focus_freeze(g, true);

View File

@ -96,15 +96,15 @@ class KeyboardEncoder:
self.kb = lv.keyboard(lv.screen_active())
self.kb.add_flag(lv.obj.FLAG.HIDDEN)
ta1.add_event(self.ta_event_cb, lv.EVENT.ALL, None)
ta2.add_event(self.ta_event_cb, lv.EVENT.ALL, None)
ta1.add_event_cb(self.ta_event_cb, lv.EVENT.ALL, None)
ta2.add_event_cb(self.ta_event_cb, lv.EVENT.ALL, None)
def msgbox_create(self):
buttons = ["Ok", "Cancel", ""]
mbox = lv.msgbox(None, "Hi", "Welcome to the keyboard and encoder demo", buttons, False)
mbox.add_event(self.msgbox_event_cb, lv.EVENT.ALL, None)
mbox.add_event_cb(self.msgbox_event_cb, lv.EVENT.ALL, None)
lv.group_focus_obj(mbox.get_buttons())
mbox.get_buttons().add_state(lv.STATE.FOCUS_KEY)
self.g.focus_freeze(True)

View File

@ -295,7 +295,7 @@ static void card_create(lv_obj_t * parent, card_info_t * info)
lv_obj_t * cont = lv_obj_create(parent);
lv_obj_add_style(cont, &style_card_cont, 0);
lv_obj_set_scroll_snap_x(cont, LV_SCROLL_SNAP_CENTER);
lv_obj_add_event(cont, scroll_event_cb, LV_EVENT_RELEASED, NULL);
lv_obj_add_event_cb(cont, scroll_event_cb, LV_EVENT_RELEASED, NULL);
lv_obj_remove_flag(cont, LV_OBJ_FLAG_SCROLL_ELASTIC);
lv_obj_set_scrollbar_mode(cont, LV_SCROLLBAR_MODE_OFF);

View File

@ -130,7 +130,7 @@ lv_obj_t * _lv_demo_music_list_create(lv_obj_t * parent)
/*Create an empty transparent container*/
list = lv_obj_create(parent);
lv_obj_add_event(list, list_delete_event_cb, LV_EVENT_DELETE, NULL);
lv_obj_add_event_cb(list, list_delete_event_cb, LV_EVENT_DELETE, NULL);
lv_obj_remove_style_all(list);
lv_obj_set_size(list, LV_HOR_RES, LV_VER_RES - LV_DEMO_MUSIC_HANDLE_SIZE);
lv_obj_set_y(list, LV_DEMO_MUSIC_HANDLE_SIZE);
@ -191,7 +191,7 @@ static lv_obj_t * add_list_button(lv_obj_t * parent, uint32_t track_id)
lv_obj_add_style(btn, &style_button_pr, LV_STATE_PRESSED);
lv_obj_add_style(btn, &style_button_chk, LV_STATE_CHECKED);
lv_obj_add_style(btn, &style_button_dis, LV_STATE_DISABLED);
lv_obj_add_event(btn, btn_click_event_cb, LV_EVENT_CLICKED, NULL);
lv_obj_add_event_cb(btn, btn_click_event_cb, LV_EVENT_CLICKED, NULL);
if(track_id >= 3) {
lv_obj_add_state(btn, LV_STATE_DISABLED);

View File

@ -545,7 +545,7 @@ static lv_obj_t * create_spectrum_obj(lv_obj_t * parent)
lv_obj_set_height(obj, 250);
#endif
lv_obj_remove_flag(obj, LV_OBJ_FLAG_CLICKABLE | LV_OBJ_FLAG_SCROLLABLE);
lv_obj_add_event(obj, spectrum_draw_event_cb, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(obj, spectrum_draw_event_cb, LV_EVENT_ALL, NULL);
lv_obj_refresh_ext_draw_size(obj);
album_image_obj = album_image_create(obj);
return obj;
@ -585,7 +585,7 @@ static lv_obj_t * create_ctrl_box(lv_obj_t * parent)
icon = lv_image_create(cont);
lv_image_set_src(icon, &img_lv_demo_music_btn_prev);
lv_obj_set_grid_cell(icon, LV_GRID_ALIGN_CENTER, 2, 1, LV_GRID_ALIGN_CENTER, 0, 1);
lv_obj_add_event(icon, prev_click_event_cb, LV_EVENT_CLICKED, NULL);
lv_obj_add_event_cb(icon, prev_click_event_cb, LV_EVENT_CLICKED, NULL);
play_obj = lv_imgbtn_create(cont);
lv_imgbtn_set_src(play_obj, LV_IMGBTN_STATE_RELEASED, NULL, &img_lv_demo_music_btn_play, NULL);
@ -593,14 +593,14 @@ static lv_obj_t * create_ctrl_box(lv_obj_t * parent)
lv_obj_add_flag(play_obj, LV_OBJ_FLAG_CHECKABLE);
lv_obj_set_grid_cell(play_obj, LV_GRID_ALIGN_CENTER, 3, 1, LV_GRID_ALIGN_CENTER, 0, 1);
lv_obj_add_event(play_obj, play_event_click_cb, LV_EVENT_CLICKED, NULL);
lv_obj_add_event_cb(play_obj, play_event_click_cb, LV_EVENT_CLICKED, NULL);
lv_obj_add_flag(play_obj, LV_OBJ_FLAG_CLICKABLE);
lv_obj_set_width(play_obj, img_lv_demo_music_btn_play.header.w);
icon = lv_image_create(cont);
lv_image_set_src(icon, &img_lv_demo_music_btn_next);
lv_obj_set_grid_cell(icon, LV_GRID_ALIGN_CENTER, 4, 1, LV_GRID_ALIGN_CENTER, 0, 1);
lv_obj_add_event(icon, next_click_event_cb, LV_EVENT_CLICKED, NULL);
lv_obj_add_event_cb(icon, next_click_event_cb, LV_EVENT_CLICKED, NULL);
lv_obj_add_flag(icon, LV_OBJ_FLAG_CLICKABLE);
LV_IMAGE_DECLARE(img_lv_demo_music_slider_knob);
@ -622,14 +622,14 @@ static lv_obj_t * create_ctrl_box(lv_obj_t * parent)
lv_obj_set_style_bg_color(slider_obj, lv_color_hex(0x569af8), LV_PART_INDICATOR);
lv_obj_set_style_bg_grad_color(slider_obj, lv_color_hex(0xa666f1), LV_PART_INDICATOR);
lv_obj_set_style_outline_width(slider_obj, 0, 0);
lv_obj_add_event(slider_obj, del_counter_timer_cb, LV_EVENT_DELETE, NULL);
lv_obj_add_event_cb(slider_obj, del_counter_timer_cb, LV_EVENT_DELETE, NULL);
time_obj = lv_label_create(cont);
lv_obj_set_style_text_font(time_obj, font_small, 0);
lv_obj_set_style_text_color(time_obj, lv_color_hex(0x8a86b8), 0);
lv_label_set_text(time_obj, "0:00");
lv_obj_set_grid_cell(time_obj, LV_GRID_ALIGN_END, 5, 1, LV_GRID_ALIGN_CENTER, 1, 1);
lv_obj_add_event(time_obj, del_counter_timer_cb, LV_EVENT_DELETE, NULL);
lv_obj_add_event_cb(time_obj, del_counter_timer_cb, LV_EVENT_DELETE, NULL);
return cont;
}
@ -959,7 +959,7 @@ static lv_obj_t * album_image_create(lv_obj_t * parent)
}
lv_image_set_antialias(img, false);
lv_obj_align(img, LV_ALIGN_CENTER, 0, 0);
lv_obj_add_event(img, album_gesture_event_cb, LV_EVENT_GESTURE, NULL);
lv_obj_add_event_cb(img, album_gesture_event_cb, LV_EVENT_GESTURE, NULL);
lv_obj_remove_flag(img, LV_OBJ_FLAG_GESTURE_BUBBLE);
lv_obj_add_flag(img, LV_OBJ_FLAG_CLICKABLE);

View File

@ -539,7 +539,7 @@ static lv_obj_t * triangle_obj_create(lv_obj_t * parent, int32_t col, int32_t ro
lv_obj_set_size(obj, DEF_WIDTH, DEF_HEIGHT);
lv_obj_set_style_bg_color(obj, lv_color_hex3(0xff0), 0);
lv_obj_set_style_opa(obj, opa_saved, 0);
lv_obj_add_event(obj, triangle_draw_event_cb, LV_EVENT_DRAW_MAIN, p);
lv_obj_add_event_cb(obj, triangle_draw_event_cb, LV_EVENT_DRAW_MAIN, p);
add_to_cell(obj, col, row);
return obj;

View File

@ -87,7 +87,7 @@ static lv_obj_t * switch_create(lv_obj_t * parent, const char * title, lv_obj_fl
lv_obj_set_flex_grow(label, 1);
lv_obj_t * sw = lv_switch_create(cont);
lv_obj_add_event(sw, generic_switch_event_cb, LV_EVENT_VALUE_CHANGED, (void *)((lv_uintptr_t) flag));
lv_obj_add_event_cb(sw, generic_switch_event_cb, LV_EVENT_VALUE_CHANGED, (void *)((lv_uintptr_t) flag));
if(en) {
lv_obj_add_state(sw, LV_STATE_CHECKED);
lv_obj_add_flag(list, flag);

View File

@ -96,14 +96,14 @@ void lv_demo_transform(void)
lv_obj_set_size(arc, disp_w - 20, disp_w - 20);
lv_arc_set_range(arc, 0, 270);
lv_arc_set_value(arc, 225);
lv_obj_add_event(arc, arc_event_cb, LV_EVENT_VALUE_CHANGED, NULL);
lv_obj_add_event_cb(arc, arc_event_cb, LV_EVENT_VALUE_CHANGED, NULL);
lv_obj_add_flag(arc, LV_OBJ_FLAG_ADV_HITTEST);
lv_obj_center(arc);
lv_obj_t * slider = lv_slider_create(lv_screen_active());
lv_obj_set_width(slider, lv_pct(70));
lv_obj_align(slider, LV_ALIGN_BOTTOM_MID, 0, -20);
lv_obj_add_event(slider, slider_event_cb, LV_EVENT_VALUE_CHANGED, NULL);
lv_obj_add_event_cb(slider, slider_event_cb, LV_EVENT_VALUE_CHANGED, NULL);
lv_slider_set_range(slider, 128, 300);
lv_slider_set_value(slider, 256, LV_ANIM_OFF);
}

View File

@ -179,7 +179,7 @@ void lv_demo_widgets(void)
tv = lv_tabview_create(lv_screen_active());
lv_tabview_set_tab_bar_size(tv, tab_h);
lv_obj_add_event(tv, tabview_delete_event_cb, LV_EVENT_DELETE, NULL);
lv_obj_add_event_cb(tv, tabview_delete_event_cb, LV_EVENT_DELETE, NULL);
lv_obj_set_style_text_font(lv_screen_active(), font_normal, 0);
@ -308,7 +308,7 @@ static void profile_create(lv_obj_t * parent)
lv_obj_t * user_name = lv_textarea_create(panel2);
lv_textarea_set_one_line(user_name, true);
lv_textarea_set_placeholder_text(user_name, "Your name");
lv_obj_add_event(user_name, ta_event_cb, LV_EVENT_ALL, kb);
lv_obj_add_event_cb(user_name, ta_event_cb, LV_EVENT_ALL, kb);
lv_obj_t * password_label = lv_label_create(panel2);
lv_label_set_text(password_label, "Password");
@ -318,7 +318,7 @@ static void profile_create(lv_obj_t * parent)
lv_textarea_set_one_line(password, true);
lv_textarea_set_password_mode(password, true);
lv_textarea_set_placeholder_text(password, "Min. 8 chars.");
lv_obj_add_event(password, ta_event_cb, LV_EVENT_ALL, kb);
lv_obj_add_event_cb(password, ta_event_cb, LV_EVENT_ALL, kb);
lv_obj_t * gender_label = lv_label_create(panel2);
lv_label_set_text(gender_label, "Gender");
@ -333,7 +333,7 @@ static void profile_create(lv_obj_t * parent)
lv_obj_t * birthdate = lv_textarea_create(panel2);
lv_textarea_set_one_line(birthdate, true);
lv_obj_add_event(birthdate, birthday_event_cb, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(birthdate, birthday_event_cb, LV_EVENT_ALL, NULL);
/*Create the third panel*/
lv_obj_t * panel3 = lv_obj_create(parent);
@ -347,7 +347,7 @@ static void profile_create(lv_obj_t * parent)
lv_obj_t * slider1 = lv_slider_create(panel3);
lv_obj_set_width(slider1, LV_PCT(95));
lv_obj_add_event(slider1, slider_event_cb, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(slider1, slider_event_cb, LV_EVENT_ALL, NULL);
lv_obj_add_flag(slider1, LV_OBJ_FLAG_SEND_DRAW_TASK_EVENTS);
lv_obj_refresh_ext_draw_size(slider1);
@ -597,7 +597,7 @@ static lv_obj_t * create_chart_with_scales(lv_obj_t * parent, const char * title
lv_chart_set_point_count(chart, 12);
lv_obj_set_grid_cell(chart, LV_GRID_ALIGN_START, 0, 1, LV_GRID_ALIGN_STRETCH, 0, 1);
lv_obj_set_style_border_width(chart, 0, 0);
lv_obj_add_event(chart, chart_event_cb, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(chart, chart_event_cb, LV_EVENT_ALL, NULL);
lv_obj_set_width(chart, lv_pct(200));
lv_obj_set_style_radius(chart, 0, 0);
@ -774,7 +774,7 @@ static void analytics_create(lv_obj_t * parent)
lv_obj_center(arc);
lv_timer_t * scale2_timer = lv_timer_create(scale2_timer_cb, 100, scale2);
lv_obj_add_event(scale2, delete_timer_event_cb, LV_EVENT_DELETE, scale2_timer);
lv_obj_add_event_cb(scale2, delete_timer_event_cb, LV_EVENT_DELETE, scale2_timer);
/*Scale 3*/
lv_scale_set_range(scale3, 10, 60);
@ -820,7 +820,7 @@ static void analytics_create(lv_obj_t * parent)
lv_style_set_line_width(&scale3_section3_tick_style, 4);
lv_style_set_line_color(&scale3_section3_tick_style, lv_palette_darken(LV_PALETTE_GREEN, 2));
lv_obj_add_event(scale3, scale3_delete_event_cb, LV_EVENT_DELETE, NULL);
lv_obj_add_event_cb(scale3, scale3_delete_event_cb, LV_EVENT_DELETE, NULL);
lv_scale_section_t * section;
section = lv_scale_add_section(scale3);
@ -896,7 +896,7 @@ void shop_create(lv_obj_t * parent)
lv_chart_set_type(chart3, LV_CHART_TYPE_BAR);
lv_chart_set_div_line_count(chart3, 6, 0);
lv_chart_set_point_count(chart3, 7);
lv_obj_add_event(chart3, shop_chart_event_cb, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(chart3, shop_chart_event_cb, LV_EVENT_ALL, NULL);
ser4 = lv_chart_add_series(chart3, lv_theme_get_color_primary(chart3), LV_CHART_AXIS_PRIMARY_Y);
lv_chart_set_next_value(chart3, ser4, lv_rand(60, 90));
@ -1068,7 +1068,7 @@ static void color_changer_create(lv_obj_t * parent)
lv_obj_set_style_radius(c, LV_RADIUS_CIRCLE, 0);
lv_obj_set_style_opa(c, LV_OPA_TRANSP, 0);
lv_obj_set_size(c, 20, 20);
lv_obj_add_event(c, color_event_cb, LV_EVENT_ALL, &palette[i]);
lv_obj_add_event_cb(c, color_event_cb, LV_EVENT_ALL, &palette[i]);
lv_obj_remove_flag(c, LV_OBJ_FLAG_SCROLL_ON_FOCUS);
}
@ -1077,7 +1077,7 @@ static void color_changer_create(lv_obj_t * parent)
lv_obj_set_style_bg_color(btn, lv_color_white(), LV_STATE_CHECKED);
lv_obj_set_style_pad_all(btn, 10, 0);
lv_obj_set_style_radius(btn, LV_RADIUS_CIRCLE, 0);
lv_obj_add_event(btn, color_changer_event_cb, LV_EVENT_ALL, color_cont);
lv_obj_add_event_cb(btn, color_changer_event_cb, LV_EVENT_ALL, color_cont);
lv_obj_set_style_shadow_width(btn, 0, 0);
lv_obj_set_style_bg_image_src(btn, LV_SYMBOL_TINT, 0);
@ -1322,7 +1322,7 @@ static void birthday_event_cb(lv_event_t * e)
else lv_obj_set_size(calendar, 300, 330);
lv_calendar_set_showed_date(calendar, 1990, 01);
lv_obj_align(calendar, LV_ALIGN_CENTER, 0, 30);
lv_obj_add_event(calendar, calendar_event_cb, LV_EVENT_ALL, ta);
lv_obj_add_event_cb(calendar, calendar_event_cb, LV_EVENT_ALL, ta);
lv_calendar_header_dropdown_create(calendar);
}

View File

@ -171,7 +171,7 @@ A callback is assigned like this:
.. code:: c
lv_obj_add_event(btn, btn_event_cb, LV_EVENT_CLICKED, NULL); /*Assign a callback to the button*/
lv_obj_add_event_cb(btn, btn_event_cb, LV_EVENT_CLICKED, NULL); /*Assign a callback to the button*/
...

View File

@ -101,8 +101,8 @@ LV_BTN
btn1.align(lv.ALIGN.TOP_MID, 0, 10)
btn2 = lv.btn(lv.screen_active())
btn2.align(lv.ALIGN.TOP_MID, 0, 50)
btn1.add_event(event_cb_1, lv.EVENT.CLICKED, 0)
btn2.add_event(event_cb_2, lv.EVENT.CLICKED, 0)
btn1.add_event_cb(event_cb_1, lv.EVENT.CLICKED, 0)
btn2.add_event_cb(event_cb_2, lv.EVENT.CLICKED, 0)
print('mem used max: %0.2f kB' % (mem.getMax()))
print('mem used now: %0.2f kB' % (mem.getNow()))

View File

@ -104,7 +104,7 @@ Usage
/* initialize X11 display driver */
lv_disp_t * disp = lv_x11_window_create("LVGL X11 Simulation", monitor_hor_res, monitor_ver_res);
lv_display_add_event(disp, on_close_cb, LV_EVENT_DELETE, disp);
lv_display_add_event_cb(disp, on_close_cb, LV_EVENT_DELETE, disp);
/* initialize X11 input drivers (for keyboard, mouse & mousewheel) */
LV_IMG_DECLARE(my_mouse_cursor_icon);

View File

@ -21,7 +21,7 @@ In practice, it looks like this:
.. code:: c
lv_obj_t * btn = lv_btn_create(lv_screen_active());
lv_obj_add_event(btn, my_event_cb, LV_EVENT_CLICKED, NULL); /*Assign an event callback*/
lv_obj_add_event_cb(btn, my_event_cb, LV_EVENT_CLICKED, NULL); /*Assign an event callback*/
...
@ -42,17 +42,17 @@ More events can be added to an object, like this:
.. code:: c
lv_obj_add_event(obj, my_event_cb_1, LV_EVENT_CLICKED, NULL);
lv_obj_add_event(obj, my_event_cb_2, LV_EVENT_PRESSED, NULL);
lv_obj_add_event(obj, my_event_cb_3, LV_EVENT_ALL, NULL); /*No filtering, receive all events*/
lv_obj_add_event_cb(obj, my_event_cb_1, LV_EVENT_CLICKED, NULL);
lv_obj_add_event_cb(obj, my_event_cb_2, LV_EVENT_PRESSED, NULL);
lv_obj_add_event_cb(obj, my_event_cb_3, LV_EVENT_ALL, NULL); /*No filtering, receive all events*/
Even the same event callback can be used on an object with different
``user_data``. For example:
.. code:: c
lv_obj_add_event(obj, increment_on_click, LV_EVENT_CLICKED, &num1);
lv_obj_add_event(obj, increment_on_click, LV_EVENT_CLICKED, &num2);
lv_obj_add_event_cb(obj, increment_on_click, LV_EVENT_CLICKED, &num1);
lv_obj_add_event_cb(obj, increment_on_click, LV_EVENT_CLICKED, &num2);
The events will be called in the order as they were added.

View File

@ -65,7 +65,7 @@ event. For example:
...
lv_obj_add_event(screen1, my_event, LV_EVENT_GESTURE, NULL);
lv_obj_add_event_cb(screen1, my_event, LV_EVENT_GESTURE, NULL);
To prevent passing the gesture event to the parent from an object use
:cpp:expr:`lv_obj_remove_flag(obj, LV_OBJ_FLAG_GESTURE_BUBBLE)`.

View File

@ -225,7 +225,7 @@ to combine scroll event and store the scroll top position.
}
lv_obj_t* container = lv_obj_create(NULL);
lv_obj_add_event(container, store_scroll_value_event_cb, LV_EVENT_SCROLL, NULL);
lv_obj_add_event_cb(container, store_scroll_value_event_cb, LV_EVENT_SCROLL, NULL);
Scroll coordinates can be retrieved from different axes with these
functions:

View File

@ -198,7 +198,7 @@ be stored in display object.
Events
******
:cpp:expr:`lv_disp_add_event(disp, event_cb, LV_DISP_EVENT_..., user_data)` adds
:cpp:expr:`lv_disp_add_event_cb(disp, event_cb, LV_DISP_EVENT_..., user_data)` adds
an event handler to a display. The following events are sent:
- :cpp:enumerator:`LV_DISP_EVENT_INVALIDATE_AREA` An area is invalidated (marked for redraw).

View File

@ -128,7 +128,7 @@ Events
------
To set an event callback for an object, use
:cpp:expr:`lv_obj_add_event(obj, event_cb, LV_EVENT_..., user_data)`,
:cpp:expr:`lv_obj_add_event_cb(obj, event_cb, LV_EVENT_..., user_data)`,
To manually send an event to an object, use
:cpp:expr:`lv_event_send(obj, LV_EVENT_..., param)`

View File

@ -81,12 +81,12 @@ void eventLicener_registerEvent(PikaObj* self,
strsDeinit(&buffs);
}
void pika_lvgl_lv_obj_add_event(PikaObj* self,
void pika_lvgl_lv_obj_add_event_cb(PikaObj* self,
Arg* event_cb,
int filter,
void* user_data) {
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
lv_obj_add_event(lv_obj, __pika_event_cb, filter, NULL);
lv_obj_add_event_cb(lv_obj, __pika_event_cb, filter, NULL);
obj_setArg(self, "_event_cb", event_cb);
obj_setPtr(self, "_event_user_data", user_data);
obj_newDirectObj(self, "_event_evt", New_pika_lvgl_lv_event);

View File

@ -46,7 +46,7 @@ void lv_example_anim_1(void)
lv_obj_t * sw = lv_switch_create(lv_screen_active());
lv_obj_center(sw);
lv_obj_add_state(sw, LV_STATE_CHECKED);
lv_obj_add_event(sw, sw_event_cb, LV_EVENT_VALUE_CHANGED, label);
lv_obj_add_event_cb(sw, sw_event_cb, LV_EVENT_VALUE_CHANGED, label);
}
#endif

View File

@ -35,7 +35,7 @@ label.set_pos(100, 10)
sw = lv.switch(lv.screen_active())
sw.center()
sw.add_state(lv.STATE.CHECKED)
sw.add_event(lambda e: sw_event_cb(e,label), lv.EVENT.VALUE_CHANGED, None)
sw.add_event_cb(lambda e: sw_event_cb(e,label), lv.EVENT.VALUE_CHANGED, None)

View File

@ -139,13 +139,13 @@ static void page_obj_init(lv_obj_t * par)
lv_slider_set_range(ginfo.p2_slider, 0, 1024);
lv_obj_set_style_pad_all(ginfo.p1_slider, 2, LV_PART_KNOB);
lv_obj_set_style_pad_all(ginfo.p2_slider, 2, LV_PART_KNOB);
lv_obj_add_event(ginfo.p1_slider, slider_event_cb, LV_EVENT_VALUE_CHANGED, NULL);
lv_obj_add_event(ginfo.p2_slider, slider_event_cb, LV_EVENT_VALUE_CHANGED, NULL);
lv_obj_add_event_cb(ginfo.p1_slider, slider_event_cb, LV_EVENT_VALUE_CHANGED, NULL);
lv_obj_add_event_cb(ginfo.p2_slider, slider_event_cb, LV_EVENT_VALUE_CHANGED, NULL);
lv_obj_set_grid_cell(ginfo.p1_slider, LV_GRID_ALIGN_STRETCH, 1, 1, LV_GRID_ALIGN_START, 1, 1);
lv_obj_set_grid_cell(ginfo.p2_slider, LV_GRID_ALIGN_STRETCH, 1, 1, LV_GRID_ALIGN_START, 2, 1);
ginfo.run_btn = lv_button_create(par);
lv_obj_add_event(ginfo.run_btn, run_button_event_handler, LV_EVENT_CLICKED, NULL);
lv_obj_add_event_cb(ginfo.run_btn, run_button_event_handler, LV_EVENT_CLICKED, NULL);
lv_obj_t * btn_label = lv_label_create(ginfo.run_btn);
lv_label_set_text(btn_label, LV_SYMBOL_PLAY);
lv_obj_center(btn_label);

View File

@ -59,13 +59,13 @@ class LvExampleAnim_3():
self.p2_slider.set_range(0, 1024)
self.p1_slider.set_style_pad_all(2, lv.PART.KNOB)
self.p2_slider.set_style_pad_all(2, lv.PART.KNOB)
self.p1_slider.add_event(self.slider_event_cb, lv.EVENT.VALUE_CHANGED, None)
self.p2_slider.add_event(self.slider_event_cb, lv.EVENT.VALUE_CHANGED, None)
self.p1_slider.add_event_cb(self.slider_event_cb, lv.EVENT.VALUE_CHANGED, None)
self.p2_slider.add_event_cb(self.slider_event_cb, lv.EVENT.VALUE_CHANGED, None)
self.p1_slider.set_grid_cell(lv.GRID_ALIGN.STRETCH, 1, 1,lv.GRID_ALIGN.START, 1, 1)
self.p2_slider.set_grid_cell(lv.GRID_ALIGN.STRETCH, 1, 1,lv.GRID_ALIGN.START, 2, 1)
self.run_button = lv.button(par)
self.run_button.add_event(self.run_button_event_handler, lv.EVENT.CLICKED, None)
self.run_button.add_event_cb(self.run_button_event_handler, lv.EVENT.CLICKED, None)
button_label = lv.label(self.run_button)
button_label.set_text(lv.SYMBOL.PLAY)
button_label.center()

View File

@ -142,7 +142,7 @@ void lv_example_anim_timeline_1(void)
/* create btn_start */
lv_obj_t * btn_start = lv_button_create(par);
lv_obj_add_event(btn_start, btn_start_event_handler, LV_EVENT_VALUE_CHANGED, NULL);
lv_obj_add_event_cb(btn_start, btn_start_event_handler, LV_EVENT_VALUE_CHANGED, NULL);
lv_obj_add_flag(btn_start, LV_OBJ_FLAG_IGNORE_LAYOUT);
lv_obj_add_flag(btn_start, LV_OBJ_FLAG_CHECKABLE);
lv_obj_align(btn_start, LV_ALIGN_TOP_MID, -100, 20);
@ -153,7 +153,7 @@ void lv_example_anim_timeline_1(void)
/* create btn_del */
lv_obj_t * btn_del = lv_button_create(par);
lv_obj_add_event(btn_del, btn_delete_event_handler, LV_EVENT_CLICKED, NULL);
lv_obj_add_event_cb(btn_del, btn_delete_event_handler, LV_EVENT_CLICKED, NULL);
lv_obj_add_flag(btn_del, LV_OBJ_FLAG_IGNORE_LAYOUT);
lv_obj_align(btn_del, LV_ALIGN_TOP_MID, 0, 20);
@ -163,7 +163,7 @@ void lv_example_anim_timeline_1(void)
/* create btn_stop */
lv_obj_t * btn_stop = lv_button_create(par);
lv_obj_add_event(btn_stop, btn_stop_event_handler, LV_EVENT_CLICKED, NULL);
lv_obj_add_event_cb(btn_stop, btn_stop_event_handler, LV_EVENT_CLICKED, NULL);
lv_obj_add_flag(btn_stop, LV_OBJ_FLAG_IGNORE_LAYOUT);
lv_obj_align(btn_stop, LV_ALIGN_TOP_MID, 100, 20);
@ -173,7 +173,7 @@ void lv_example_anim_timeline_1(void)
/* create slider_prg */
lv_obj_t * slider_prg = lv_slider_create(par);
lv_obj_add_event(slider_prg, slider_prg_event_handler, LV_EVENT_VALUE_CHANGED, NULL);
lv_obj_add_event_cb(slider_prg, slider_prg_event_handler, LV_EVENT_VALUE_CHANGED, NULL);
lv_obj_add_flag(slider_prg, LV_OBJ_FLAG_IGNORE_LAYOUT);
lv_obj_align(slider_prg, LV_ALIGN_BOTTOM_MID, 0, -20);
lv_slider_set_range(slider_prg, 0, 65535);

View File

@ -12,7 +12,7 @@ class LV_ExampleAnimTimeline_1(object):
self.par.set_flex_align(lv.FLEX_ALIGN.SPACE_AROUND, lv.FLEX_ALIGN.CENTER, lv.FLEX_ALIGN.CENTER)
self.button_run = lv.button(self.par)
self.button_run.add_event(self.button_run_event_handler, lv.EVENT.VALUE_CHANGED, None)
self.button_run.add_event_cb(self.button_run_event_handler, lv.EVENT.VALUE_CHANGED, None)
self.button_run.add_flag(lv.obj.FLAG.IGNORE_LAYOUT)
self.button_run.add_flag(lv.obj.FLAG.CHECKABLE)
self.button_run.align(lv.ALIGN.TOP_MID, -50, 20)
@ -22,7 +22,7 @@ class LV_ExampleAnimTimeline_1(object):
self.label_run.center()
self.button_del = lv.button(self.par)
self.button_del.add_event(self.button_delete_event_handler, lv.EVENT.CLICKED, None)
self.button_del.add_event_cb(self.button_delete_event_handler, lv.EVENT.CLICKED, None)
self.button_del.add_flag(lv.obj.FLAG.IGNORE_LAYOUT)
self.button_del.align(lv.ALIGN.TOP_MID, 50, 20)
@ -31,7 +31,7 @@ class LV_ExampleAnimTimeline_1(object):
self.label_del.center()
self.slider = lv.slider(self.par)
self.slider.add_event(self.slider_prg_event_handler, lv.EVENT.VALUE_CHANGED, None)
self.slider.add_event_cb(self.slider_prg_event_handler, lv.EVENT.VALUE_CHANGED, None)
self.slider.add_flag(lv.obj.FLAG.IGNORE_LAYOUT)
self.slider.align(lv.ALIGN.BOTTOM_RIGHT, -20, -20)
self.slider.set_range(0, 65535)

View File

@ -20,7 +20,7 @@ void lv_example_event_1(void)
lv_obj_t * btn = lv_button_create(lv_screen_active());
lv_obj_set_size(btn, 100, 50);
lv_obj_center(btn);
lv_obj_add_event(btn, event_cb, LV_EVENT_CLICKED, NULL);
lv_obj_add_event_cb(btn, event_cb, LV_EVENT_CLICKED, NULL);
lv_obj_t * label = lv_label_create(btn);
lv_label_set_text(label, "Click me!");

View File

@ -8,7 +8,7 @@ class Event_1():
button = lv.button(lv.screen_active())
button.set_size(100, 50)
button.center()
button.add_event(self.event_cb, lv.EVENT.CLICKED, None)
button.add_event_cb(self.event_cb, lv.EVENT.CLICKED, None)
label = lv.label(button)
label.set_text("Click me!")

View File

@ -40,7 +40,7 @@ void lv_example_event_2(void)
lv_obj_t * info_label = lv_label_create(lv_screen_active());
lv_label_set_text(info_label, "The last button event:\nNone");
lv_obj_add_event(btn, event_cb, LV_EVENT_ALL, info_label);
lv_obj_add_event_cb(btn, event_cb, LV_EVENT_ALL, info_label);
}
#endif

View File

@ -19,4 +19,4 @@ button_label.center()
info_label = lv.label(lv.screen_active())
info_label.set_text("The last button event:\nNone")
button.add_event(lambda e: event_cb(e,info_label), lv.EVENT.ALL, None)
button.add_event_cb(lambda e: event_cb(e,info_label), lv.EVENT.ALL, None)

View File

@ -38,7 +38,7 @@ void lv_example_event_3(void)
lv_obj_center(label);
}
lv_obj_add_event(cont, event_cb, LV_EVENT_CLICKED, NULL);
lv_obj_add_event_cb(cont, event_cb, LV_EVENT_CLICKED, NULL);
}
#endif

View File

@ -31,4 +31,4 @@ for i in range(30):
label.set_text("{:d}".format(i))
label.center()
cont.add_event(event_cb, lv.EVENT.CLICKED, None)
cont.add_event_cb(event_cb, lv.EVENT.CLICKED, None)

View File

@ -50,7 +50,7 @@ void lv_example_event_4(void)
lv_obj_t * cont = lv_obj_create(lv_screen_active());
lv_obj_set_size(cont, 200, 200);
lv_obj_center(cont);
lv_obj_add_event(cont, event_cb, LV_EVENT_DRAW_TASK_ADDED, NULL);
lv_obj_add_event_cb(cont, event_cb, LV_EVENT_DRAW_TASK_ADDED, NULL);
lv_obj_add_flag(cont, LV_OBJ_FLAG_SEND_DRAW_TASK_EVENTS);
lv_timer_create(timer_cb, 30, cont);
}

View File

@ -9,7 +9,7 @@ class LV_Example_Event_4:
self.cont = lv.obj(lv.screen_active())
self.cont.set_size(200, 200)
self.cont.center()
self.cont.add_event(self.event_cb, lv.EVENT.DRAW_TASK_ADDED, None)
self.cont.add_event_cb(self.event_cb, lv.EVENT.DRAW_TASK_ADDED, None)
self.cont.add_flag(lv.obj.FLAG.SEND_DRAW_TASK_EVENTS)
lv.timer_create(self.timer_cb, 30, None)

View File

@ -23,7 +23,7 @@ void lv_example_get_started_2(void)
lv_obj_t * btn = lv_button_create(lv_screen_active()); /*Add a button the current screen*/
lv_obj_set_pos(btn, 10, 10); /*Set its position*/
lv_obj_set_size(btn, 120, 50); /*Set its size*/
lv_obj_add_event(btn, btn_event_cb, LV_EVENT_ALL, NULL); /*Assign a callback to the button*/
lv_obj_add_event_cb(btn, btn_event_cb, LV_EVENT_ALL, NULL); /*Assign a callback to the button*/
lv_obj_t * label = lv_label_create(btn); /*Add a label to the button*/
lv_label_set_text(label, "Button"); /*Set the labels text*/

View File

@ -9,7 +9,7 @@ class CounterBtn():
button.set_pos(10, 10) # Set its position
button.set_size(120, 50) # Set its size
button.align(lv.ALIGN.CENTER,0,0)
button.add_event(self.button_event_cb, lv.EVENT.ALL, None) # Assign a callback to the button
button.add_event_cb(self.button_event_cb, lv.EVENT.ALL, None) # Assign a callback to the button
label = lv.label(button) # Add a label to the button
label.set_text("Button") # Set the labels text
label.center()

View File

@ -21,7 +21,7 @@ void lv_example_get_started_4(void)
lv_obj_t * slider = lv_slider_create(lv_screen_active());
lv_obj_set_width(slider, 200); /*Set the width*/
lv_obj_center(slider); /*Align to the center of the parent (screen)*/
lv_obj_add_event(slider, slider_event_cb, LV_EVENT_VALUE_CHANGED, NULL); /*Assign an event function*/
lv_obj_add_event_cb(slider, slider_event_cb, LV_EVENT_VALUE_CHANGED, NULL); /*Assign an event function*/
/*Create a label above the slider*/
label = lv_label_create(lv_screen_active());

View File

@ -12,7 +12,7 @@ def slider_event_cb(e):
slider = lv.slider(lv.screen_active())
slider.set_width(200) # Set the width
slider.center() # Align to the center of the parent (screen)
slider.add_event(slider_event_cb, lv.EVENT.VALUE_CHANGED, None) # Assign an event function
slider.add_event_cb(slider_event_cb, lv.EVENT.VALUE_CHANGED, None) # Assign an event function
# Create a label above the slider
label = lv.label(lv.screen_active())

View File

@ -78,7 +78,7 @@ void lv_example_file_explorer_1(void)
#endif
#endif
lv_obj_add_event(file_explorer, file_explorer_event_handler, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(file_explorer, file_explorer_event_handler, LV_EVENT_ALL, NULL);
}
#endif

View File

@ -43,5 +43,5 @@ if LV_FILE_EXPLORER_QUICK_ACCESS :
file_explorer.explorer_set_quick_access_path(lv.EXPLORER.DOCS_DIR, home_dir + "/Documents")
file_explorer.explorer_set_quick_access_path(lv.EXPLORER.FS_DIR, "A:/")
file_explorer.add_event(file_explorer_event_handler, lv.EVENT.ALL, None)
file_explorer.add_event_cb(file_explorer_event_handler, lv.EVENT.ALL, None)

View File

@ -108,7 +108,7 @@ void lv_example_file_explorer_2(void)
#endif
#endif
lv_obj_add_event(file_explorer, file_explorer_event_handler, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(file_explorer, file_explorer_event_handler, LV_EVENT_ALL, NULL);
/*Quick access status control button*/
lv_obj_t * fe_quick_access_obj = lv_file_explorer_get_quick_access_area(file_explorer);
@ -123,7 +123,7 @@ void lv_example_file_explorer_2(void)
lv_label_set_text(label, LV_SYMBOL_LIST);
lv_obj_center(label);
lv_obj_add_event(btn, btn_event_handler, LV_EVENT_VALUE_CHANGED, fe_quick_access_obj);
lv_obj_add_event_cb(btn, btn_event_handler, LV_EVENT_VALUE_CHANGED, fe_quick_access_obj);
/*Sort control*/
static const char * opts = "NONE\n"
@ -136,7 +136,7 @@ void lv_example_file_explorer_2(void)
lv_dropdown_set_options_static(dd, opts);
lv_obj_align(dd, LV_ALIGN_RIGHT_MID, 0, 0);
lv_obj_add_event(dd, dd_event_handler, LV_EVENT_VALUE_CHANGED, file_explorer);
lv_obj_add_event_cb(dd, dd_event_handler, LV_EVENT_VALUE_CHANGED, file_explorer);
}
#endif

View File

@ -68,7 +68,7 @@ if LV_FILE_EXPLORER_QUICK_ACCESS :
file_explorer.explorer_set_quick_access_path(lv.EXPLORER.DOCS_DIR, home_dir + "/Documents")
file_explorer.explorer_set_quick_access_path(lv.EXPLORER.FS_DIR, "A:/")
file_explorer.add_event(file_explorer_event_handler, lv.EVENT.ALL, None)
file_explorer.add_event_cb(file_explorer_event_handler, lv.EVENT.ALL, None)
# Quick access status control button
fe_quick_access_obj = file_explorer.explorer_get_quick_access_area()
@ -83,8 +83,8 @@ label = lv.label(button)
label.set_text(lv.SYMBOL.LIST)
label.center()
button.add_event(lambda evt: button_event_handler(evt,fe_quick_access_obj), lv.EVENT.VALUE_CHANGED, None)
#button.add_event(lambda evt: button_event_handler(evt,file_explorer), lv.EVENT.VALUE_CHANGED, None)
button.add_event_cb(lambda evt: button_event_handler(evt,fe_quick_access_obj), lv.EVENT.VALUE_CHANGED, None)
#button.add_event_cb(lambda evt: button_event_handler(evt,file_explorer), lv.EVENT.VALUE_CHANGED, None)
# Sort control
opts = "NONE\nKIND"
@ -97,6 +97,6 @@ dd.set_options_static(opts)
dd.align(lv.ALIGN.RIGHT_MID, 0, 0)
# lv_obj_align_to(dd, button, LV_ALIGN_OUT_RIGHT_MID, 0, 0);
dd.add_event(lambda evt: dd_event_handler(evt,file_explorer), lv.EVENT.VALUE_CHANGED, None)
#dd.add_event(lambda evt: dd_event_handler(evt,fe_quick_access_obj), lv.EVENT.VALUE_CHANGED, None)
dd.add_event_cb(lambda evt: dd_event_handler(evt,file_explorer), lv.EVENT.VALUE_CHANGED, None)
#dd.add_event_cb(lambda evt: dd_event_handler(evt,fe_quick_access_obj), lv.EVENT.VALUE_CHANGED, None)

View File

@ -120,7 +120,7 @@ void lv_example_file_explorer_3(void)
#endif
#endif
lv_obj_add_event(file_explorer, file_explorer_event_handler, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(file_explorer, file_explorer_event_handler, LV_EVENT_ALL, NULL);
}
#endif

View File

@ -86,4 +86,4 @@ if LV_FILE_EXPLORER_QUICK_ACCESS :
file_explorer.explorer_set_quick_access_path(lv.EXPLORER.DOCS_DIR, home_dir + "/Documents")
file_explorer.explorer_set_quick_access_path(lv.EXPLORER.FS_DIR, "A:/")
file_explorer.add_event(file_explorer_event_handler, lv.EVENT.ALL, None)
file_explorer.add_event_cb(file_explorer_event_handler, lv.EVENT.ALL, None)

View File

@ -31,7 +31,7 @@ void lv_example_fragment_1(void)
lv_obj_set_size(root, LV_PCT(100), LV_PCT(100));
lv_fragment_manager_t * manager = lv_fragment_manager_create(NULL);
/* Clean up the fragment manager before objects in containers got deleted */
lv_obj_add_event(root, sample_container_delete, LV_EVENT_DELETE, manager);
lv_obj_add_event_cb(root, sample_container_delete, LV_EVENT_DELETE, manager);
lv_fragment_t * fragment = lv_fragment_create(&sample_cls, "Fragment");
lv_fragment_manager_replace(manager, fragment, &root);

View File

@ -57,13 +57,13 @@ void lv_example_fragment_2(void)
lv_fragment_manager_t * manager = lv_fragment_manager_create(NULL);
/* Clean up the fragment manager before objects in containers got deleted */
lv_obj_add_event(root, sample_container_delete, LV_EVENT_DELETE, manager);
lv_obj_add_event_cb(root, sample_container_delete, LV_EVENT_DELETE, manager);
int depth = 0;
lv_fragment_t * fragment = lv_fragment_create(&sample_cls, &depth);
lv_fragment_manager_push(manager, fragment, &container);
lv_obj_add_event(push_btn, sample_push_click, LV_EVENT_CLICKED, manager);
lv_obj_add_event(pop_btn, sample_pop_click, LV_EVENT_CLICKED, manager);
lv_obj_add_event_cb(push_btn, sample_push_click, LV_EVENT_CLICKED, manager);
lv_obj_add_event_cb(pop_btn, sample_pop_click, LV_EVENT_CLICKED, manager);
}
static void sample_fragment_ctor(lv_fragment_t * self, void * args)
@ -91,7 +91,7 @@ static lv_obj_t * sample_fragment_create_obj(lv_fragment_t * self, lv_obj_t * pa
lv_obj_t * inc_btn = lv_button_create(content);
lv_obj_t * inc_label = lv_label_create(inc_btn);
lv_label_set_text(inc_label, "+1");
lv_obj_add_event(inc_btn, sample_fragment_inc_click, LV_EVENT_CLICKED, fragment);
lv_obj_add_event_cb(inc_btn, sample_fragment_inc_click, LV_EVENT_CLICKED, fragment);
return content;
}

View File

@ -71,7 +71,7 @@ void lv_example_gridnav_3(void)
/*Only the container needs to be in a group*/
lv_group_add_obj(lv_group_get_default(), cont_sub2);
lv_obj_add_event(cont_sub2, cont_sub_event_cb, LV_EVENT_KEY, NULL);
lv_obj_add_event_cb(cont_sub2, cont_sub_event_cb, LV_EVENT_KEY, NULL);
/*Use flex here, but works with grid or manually placed objects as well*/
lv_obj_set_flex_flow(cont_sub2, LV_FLEX_FLOW_ROW_WRAP);

View File

@ -61,7 +61,7 @@ lv.gridnav_add(cont_sub2, lv.GRIDNAV_CTRL.ROLLOVER)
#Only the container needs to be in a group
lv.group_get_default().add_obj(cont_sub2)
cont_sub2.add_event(cont_sub_event_cb, lv.EVENT.KEY, None)
cont_sub2.add_event_cb(cont_sub_event_cb, lv.EVENT.KEY, None)
# Use flex here, but works with grid or manually placed objects as well
cont_sub2.set_flex_flow(lv.FLEX_FLOW.ROW_WRAP)

View File

@ -33,7 +33,7 @@ void lv_example_gridnav_4(void)
lv_snprintf(buf, sizeof(buf), "File %d", i + 1);
lv_obj_t * item = lv_list_add_button(list, LV_SYMBOL_FILE, buf);
lv_obj_add_event(item, event_handler, LV_EVENT_CLICKED, NULL);
lv_obj_add_event_cb(item, event_handler, LV_EVENT_CLICKED, NULL);
lv_group_remove_obj(item); /*The default group adds it automatically*/
}

View File

@ -26,7 +26,7 @@ for i in range(20):
txt = "File {:d}".format(i + 1)
#lv_snprintf(buf, sizeof(buf), "File %d", i + 1);
item = list.add_button(lv.SYMBOL.FILE, txt)
item.add_event(event_handler, lv.EVENT.CLICKED, None)
item.add_event_cb(event_handler, lv.EVENT.CLICKED, None)
lv.group_remove_obj(item) # The default group adds it automatically
button = lv.button(lv.screen_active())

View File

@ -37,7 +37,7 @@ void lv_example_ime_pinyin_1(void)
lv_ime_pinyin_set_keyboard(pinyin_ime, kb);
lv_keyboard_set_textarea(kb, ta1);
lv_obj_add_event(ta1, ta_event_cb, LV_EVENT_ALL, kb);
lv_obj_add_event_cb(ta1, ta_event_cb, LV_EVENT_ALL, kb);
/*Get the cand_panel, and adjust its size and position*/
lv_obj_t * cand_panel = lv_ime_pinyin_get_cand_panel(pinyin_ime);

View File

@ -36,7 +36,7 @@ kb = lv.keyboard(lv.screen_active())
pinyin_ime.pinyin_set_keyboard(kb)
kb.set_textarea(ta1)
ta1.add_event(lambda evt: ta_event_cb(evt,kb), lv.EVENT.ALL, None)
ta1.add_event_cb(lambda evt: ta_event_cb(evt,kb), lv.EVENT.ALL, None)
# Get the cand_panel, and adjust its size and position
cand_panel = pinyin_ime.pinyin_get_cand_panel()

View File

@ -39,7 +39,7 @@ void lv_example_ime_pinyin_2(void)
lv_ime_pinyin_set_keyboard(pinyin_ime, kb);
lv_ime_pinyin_set_mode(pinyin_ime,
LV_IME_PINYIN_MODE_K9); // Set to 9-key input mode. Default: 26-key input(k26) mode.
lv_obj_add_event(ta1, ta_event_cb, LV_EVENT_ALL, kb);
lv_obj_add_event_cb(ta1, ta_event_cb, LV_EVENT_ALL, kb);
/*Get the cand_panel, and adjust its size and position*/
lv_obj_t * cand_panel = lv_ime_pinyin_get_cand_panel(pinyin_ime);

View File

@ -38,7 +38,7 @@ kb.set_textarea(ta1)
pinyin_ime.pinyin_set_keyboard(kb)
pinyin_ime.pinyin_set_mode(lv.ime_pinyin.PINYIN_MODE.K9) # Set to 9-key input mode. Default: 26-key input(k26) mode.
ta1.add_event(lambda evt: ta_event_cb(evt,kb), lv.EVENT.ALL, None)
ta1.add_event_cb(lambda evt: ta_event_cb(evt,kb), lv.EVENT.ALL, None)
# Get the cand_panel, and adjust its size and position
cand_panel = pinyin_ime.pinyin_get_cand_panel()

View File

@ -99,7 +99,7 @@ static void ui_init(void)
lv_textarea_set_one_line(ta, true);
lv_textarea_set_password_mode(ta, true);
lv_textarea_set_placeholder_text(ta, "The password is: hello");
lv_obj_add_event(ta, textarea_event_cb, LV_EVENT_READY, NULL);
lv_obj_add_event_cb(ta, textarea_event_cb, LV_EVENT_READY, NULL);
lv_obj_bind_state_if_eq(ta, &auth_state_subject, LV_STATE_DISABLED, LOGGED_IN);
lv_obj_t * kb = lv_keyboard_create(lv_screen_active());
@ -111,7 +111,7 @@ static void ui_init(void)
/*Create a log out button which will be active only when logged in*/
btn = lv_button_create(lv_screen_active());
lv_obj_set_pos(btn, 220, 10);
lv_obj_add_event(btn, log_out_click_event_cb, LV_EVENT_CLICKED, NULL);
lv_obj_add_event_cb(btn, log_out_click_event_cb, LV_EVENT_CLICKED, NULL);
lv_obj_bind_state_if_not_eq(btn, &auth_state_subject, LV_STATE_DISABLED, LOGGED_IN);
label = lv_label_create(btn);

View File

@ -55,7 +55,7 @@ void lv_example_observer_3(void)
lv_obj_t * set_btn = lv_button_create(lv_screen_active());
lv_obj_set_pos(set_btn, 180, 24);
lv_obj_add_event(set_btn, set_btn_clicked_event_cb, LV_EVENT_CLICKED, NULL);
lv_obj_add_event_cb(set_btn, set_btn_clicked_event_cb, LV_EVENT_CLICKED, NULL);
lv_obj_t * set_label = lv_label_create(set_btn);
lv_label_set_text(set_label, "Set");
@ -102,7 +102,7 @@ static void set_btn_clicked_event_cb(lv_event_t * e)
lv_obj_t * close_btn = lv_button_create(cont);
lv_obj_align(close_btn, LV_ALIGN_TOP_RIGHT, 0, 0);
/*Pass the set_btn as user_data to make it non-disabled on close*/
lv_obj_add_event(close_btn, close_clicked_event_cb, LV_EVENT_CLICKED, set_btn);
lv_obj_add_event_cb(close_btn, close_clicked_event_cb, LV_EVENT_CLICKED, set_btn);
lv_obj_t * close_label = lv_label_create(close_btn);
lv_label_set_text(close_label, LV_SYMBOL_CLOSE);

View File

@ -156,7 +156,7 @@ static void btn_create(lv_obj_t * parent, const char * text)
lv_obj_set_height(btn, lv_pct(100));
lv_obj_set_style_radius(btn, 0, 0);
lv_subject_add_observer_obj(&current_tab_subject, btn_observer_cb, btn, NULL);
lv_obj_add_event(btn, btn_click_event_cb, LV_EVENT_CLICKED, NULL);
lv_obj_add_event_cb(btn, btn_click_event_cb, LV_EVENT_CLICKED, NULL);
lv_obj_t * label = lv_label_create(btn);
lv_label_set_text(label, text);

View File

@ -34,7 +34,7 @@ void lv_example_observer_5(void)
/*Create start FW update button*/
lv_obj_t * btn = lv_btn_create(lv_screen_active());
lv_obj_add_event(btn, fw_update_btn_clicked_event_cb, LV_EVENT_CLICKED, NULL);
lv_obj_add_event_cb(btn, fw_update_btn_clicked_event_cb, LV_EVENT_CLICKED, NULL);
lv_obj_center(btn);
lv_obj_t * label = lv_label_create(btn);
lv_label_set_text(label, "Firmware update");
@ -53,7 +53,7 @@ static void fw_update_btn_clicked_event_cb(lv_event_t * e)
lv_obj_set_style_shadow_color(win, lv_color_hex3(0x888), 0);
lv_win_add_title(win, "Firmware update");
lv_obj_t * btn = lv_win_add_button(win, LV_SYMBOL_CLOSE, 40);
lv_obj_add_event(btn, fw_update_close_event_cb, LV_EVENT_CLICKED, NULL);
lv_obj_add_event_cb(btn, fw_update_close_event_cb, LV_EVENT_CLICKED, NULL);
lv_obj_center(win);
lv_subject_set_int(&fw_update_status_subject, FW_UPDATE_STATE_IDLE);
@ -110,7 +110,7 @@ static void fw_update_win_observer_cb(lv_subject_t * subject, lv_observer_t * ob
lv_obj_t * btn = lv_button_create(cont);
lv_obj_align(btn, LV_ALIGN_CENTER, 0, 20);
lv_obj_add_event(btn, restart_btn_click_event_cb, LV_EVENT_CLICKED, win);
lv_obj_add_event_cb(btn, restart_btn_click_event_cb, LV_EVENT_CLICKED, win);
label = lv_label_create(btn);
lv_label_set_text(label, "Restart");

View File

@ -179,7 +179,7 @@ static lv_obj_t * my_button_create(lv_obj_t * parent, const char * text, lv_even
lv_obj_remove_style_all(btn);
lv_obj_add_style(btn, &styles.style_main, 0);
lv_obj_add_style(btn, &styles.style_pressed, LV_STATE_PRESSED);
lv_obj_add_event(btn, event_cb, LV_EVENT_CLICKED, NULL);
lv_obj_add_event_cb(btn, event_cb, LV_EVENT_CLICKED, NULL);
lv_obj_t * label = lv_label_create(btn);
lv_label_set_text(label, text);

View File

@ -50,8 +50,8 @@ void lv_example_snapshot_1(void)
lv_obj_set_style_bg_opa(img, LV_OPA_COVER, 0);
// lv_obj_set_style_transform_scale(img, 400, LV_STATE_PRESSED);
lv_obj_add_flag(img, LV_OBJ_FLAG_CLICKABLE);
lv_obj_add_event(img, event_cb, LV_EVENT_PRESSED, snapshot_obj);
lv_obj_add_event(img, event_cb, LV_EVENT_RELEASED, snapshot_obj);
lv_obj_add_event_cb(img, event_cb, LV_EVENT_PRESSED, snapshot_obj);
lv_obj_add_event_cb(img, event_cb, LV_EVENT_RELEASED, snapshot_obj);
}
}

View File

@ -61,5 +61,5 @@ for i in range(4):
image.set_style_bg_opa(lv.OPA.COVER, 0)
image.set_style_transform_scale(400, lv.STATE.PRESSED)
image.add_flag(image.FLAG.CLICKABLE)
image.add_event(lambda e: event_cb(e, snapshot_obj), lv.EVENT.PRESSED, None)
image.add_event(lambda e: event_cb(e, snapshot_obj), lv.EVENT.RELEASED, None)
image.add_event_cb(lambda e: event_cb(e, snapshot_obj), lv.EVENT.PRESSED, None)
image.add_event_cb(lambda e: event_cb(e, snapshot_obj), lv.EVENT.RELEASED, None)

View File

@ -47,7 +47,7 @@ void lv_example_scroll_2(void)
/*Switch between "One scroll" and "Normal scroll" mode*/
lv_obj_t * sw = lv_switch_create(lv_screen_active());
lv_obj_align(sw, LV_ALIGN_TOP_RIGHT, -20, 10);
lv_obj_add_event(sw, sw_event_cb, LV_EVENT_ALL, panel);
lv_obj_add_event_cb(sw, sw_event_cb, LV_EVENT_ALL, panel);
lv_obj_t * label = lv_label_create(lv_screen_active());
lv_label_set_text(label, "One scroll");
lv_obj_align_to(label, sw, LV_ALIGN_OUT_BOTTOM_MID, 0, 5);

View File

@ -39,7 +39,7 @@ panel.update_snap(lv.ANIM.ON)
# Switch between "One scroll" and "Normal scroll" mode
sw = lv.switch(lv.screen_active())
sw.align(lv.ALIGN.TOP_RIGHT, -20, 10)
sw.add_event(lambda evt: sw_event_cb(evt,panel), lv.EVENT.ALL, None)
sw.add_event_cb(lambda evt: sw_event_cb(evt,panel), lv.EVENT.ALL, None)
label = lv.label(lv.screen_active())
label.set_text("One scroll")
label.align_to(sw, lv.ALIGN.OUT_BOTTOM_MID, 0, 5)

View File

@ -40,7 +40,7 @@ void lv_example_scroll_3(void)
lv_obj_set_size(float_btn, 50, 50);
lv_obj_add_flag(float_btn, LV_OBJ_FLAG_FLOATING);
lv_obj_align(float_btn, LV_ALIGN_BOTTOM_RIGHT, 0, -lv_obj_get_style_pad_right(list, LV_PART_MAIN));
lv_obj_add_event(float_btn, float_button_event_cb, LV_EVENT_ALL, list);
lv_obj_add_event_cb(float_btn, float_button_event_cb, LV_EVENT_ALL, list);
lv_obj_set_style_radius(float_btn, LV_RADIUS_CIRCLE, 0);
lv_obj_set_style_bg_image_src(float_btn, LV_SYMBOL_PLUS, 0);
lv_obj_set_style_text_font(float_btn, lv_theme_get_font_large(float_btn), 0);

View File

@ -16,7 +16,7 @@ class ScrollExample_3():
float_button.set_size(50, 50)
float_button.add_flag(lv.obj.FLAG.FLOATING)
float_button.align(lv.ALIGN.BOTTOM_RIGHT, 0, -list.get_style_pad_right(lv.PART.MAIN))
float_button.add_event(lambda evt: self.float_button_event_cb(evt,list), lv.EVENT.ALL, None)
float_button.add_event_cb(lambda evt: self.float_button_event_cb(evt,list), lv.EVENT.ALL, None)
float_button.set_style_radius(lv.RADIUS_CIRCLE, 0)
float_button.set_style_bg_image_src(lv.SYMBOL.PLUS, 0)
float_button.set_style_text_font(lv.theme_get_font_large(float_button), 0)

View File

@ -54,7 +54,7 @@ void lv_example_scroll_6(void)
lv_obj_set_size(cont, 200, 200);
lv_obj_center(cont);
lv_obj_set_flex_flow(cont, LV_FLEX_FLOW_COLUMN);
lv_obj_add_event(cont, scroll_event_cb, LV_EVENT_SCROLL, NULL);
lv_obj_add_event_cb(cont, scroll_event_cb, LV_EVENT_SCROLL, NULL);
lv_obj_set_style_radius(cont, LV_RADIUS_CIRCLE, 0);
lv_obj_set_style_clip_corner(cont, true, 0);
lv_obj_set_scroll_dir(cont, LV_DIR_VER);

View File

@ -46,7 +46,7 @@ cont = lv.obj(lv.screen_active())
cont.set_size(200, 200)
cont.center()
cont.set_flex_flow(lv.FLEX_FLOW.COLUMN)
cont.add_event(scroll_event_cb, lv.EVENT.SCROLL, None)
cont.add_event_cb(scroll_event_cb, lv.EVENT.SCROLL, None)
cont.set_style_radius(lv.RADIUS_CIRCLE, 0)
cont.set_style_clip_corner(True, 0)
cont.set_scroll_dir(lv.DIR.VER)

View File

@ -15,7 +15,7 @@ void lv_example_arc_1(void)
lv_arc_set_bg_angles(arc, 0, 270);
lv_arc_set_value(arc, 10);
lv_obj_center(arc);
lv_obj_add_event(arc, value_changed_event_cb, LV_EVENT_VALUE_CHANGED, label);
lv_obj_add_event_cb(arc, value_changed_event_cb, LV_EVENT_VALUE_CHANGED, label);
/*Manually update the label for the first time*/
lv_obj_send_event(arc, LV_EVENT_VALUE_CHANGED, NULL);

View File

@ -16,7 +16,7 @@ arc.set_rotation(135)
arc.set_bg_angles(0, 270)
arc.set_value(10)
arc.center()
arc.add_event(lambda e: value_changed_event_cb(e,label),lv.EVENT.VALUE_CHANGED, None)
arc.add_event_cb(lambda e: value_changed_event_cb(e,label),lv.EVENT.VALUE_CHANGED, None)
# Manually update the label for the first time
arc.send_event(lv.EVENT.VALUE_CHANGED, None)

View File

@ -54,7 +54,7 @@ void lv_example_bar_6(void)
lv_obj_t * bar = lv_bar_create(lv_screen_active());
lv_obj_set_size(bar, 200, 20);
lv_obj_center(bar);
lv_obj_add_event(bar, event_cb, LV_EVENT_DRAW_MAIN_END, NULL);
lv_obj_add_event_cb(bar, event_cb, LV_EVENT_DRAW_MAIN_END, NULL);
lv_anim_t a;
lv_anim_init(&a);

View File

@ -18,7 +18,7 @@ void lv_example_button_1(void)
lv_obj_t * label;
lv_obj_t * btn1 = lv_button_create(lv_screen_active());
lv_obj_add_event(btn1, event_handler, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(btn1, event_handler, LV_EVENT_ALL, NULL);
lv_obj_align(btn1, LV_ALIGN_CENTER, 0, -40);
lv_obj_remove_flag(btn1, LV_OBJ_FLAG_PRESS_LOCK);
@ -27,7 +27,7 @@ void lv_example_button_1(void)
lv_obj_center(label);
lv_obj_t * btn2 = lv_button_create(lv_screen_active());
lv_obj_add_event(btn2, event_handler, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(btn2, event_handler, LV_EVENT_ALL, NULL);
lv_obj_align(btn2, LV_ALIGN_CENTER, 0, 40);
lv_obj_add_flag(btn2, LV_OBJ_FLAG_CHECKABLE);
lv_obj_set_height(btn2, LV_SIZE_CONTENT);

View File

@ -10,7 +10,7 @@ def event_handler(evt):
button1 = lv.button(lv.screen_active())
# attach the callback
button1.add_event(event_handler,lv.EVENT.ALL, None)
button1.add_event_cb(event_handler,lv.EVENT.ALL, None)
button1.align(lv.ALIGN.CENTER,0,-40)
label=lv.label(button1)
@ -20,8 +20,8 @@ label.set_text("Button")
button2 = lv.button(lv.screen_active())
# attach the callback
#button2.add_event(event_handler,lv.EVENT.VALUE_CHANGED,None)
button2.add_event(event_handler,lv.EVENT.ALL, None)
#button2.add_event_cb(event_handler,lv.EVENT.VALUE_CHANGED,None)
button2.add_event_cb(event_handler,lv.EVENT.ALL, None)
button2.align(lv.ALIGN.CENTER,0,40)
button2.add_flag(lv.obj.FLAG.CHECKABLE)

View File

@ -26,7 +26,7 @@ void lv_example_buttonmatrix_1(void)
lv_buttonmatrix_set_button_ctrl(btnm1, 10, LV_BUTTONMATRIX_CTRL_CHECKABLE);
lv_buttonmatrix_set_button_ctrl(btnm1, 11, LV_BUTTONMATRIX_CTRL_CHECKED);
lv_obj_align(btnm1, LV_ALIGN_CENTER, 0, 0);
lv_obj_add_event(btnm1, event_handler, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(btnm1, event_handler, LV_EVENT_ALL, NULL);
}
#endif

View File

@ -18,7 +18,7 @@ buttonm1.set_button_width(10, 2) # Make "Action1" twice as wide as "Actio
buttonm1.set_button_ctrl(10, lv.buttonmatrix.CTRL.CHECKABLE)
buttonm1.set_button_ctrl(11, lv.buttonmatrix.CTRL.CHECKED)
buttonm1.align(lv.ALIGN.CENTER, 0, 0)
buttonm1.add_event(event_handler, lv.EVENT.ALL, None)
buttonm1.add_event_cb(event_handler, lv.EVENT.ALL, None)
#endif

View File

@ -76,7 +76,7 @@ static void event_cb(lv_event_t * e)
void lv_example_buttonmatrix_2(void)
{
lv_obj_t * btnm = lv_buttonmatrix_create(lv_screen_active());
lv_obj_add_event(btnm, event_cb, LV_EVENT_DRAW_TASK_ADDED, NULL);
lv_obj_add_event_cb(btnm, event_cb, LV_EVENT_DRAW_TASK_ADDED, NULL);
lv_obj_add_flag(btnm, LV_OBJ_FLAG_SEND_DRAW_TASK_EVENTS);
lv_obj_center(btnm);
}

View File

@ -49,7 +49,7 @@ void lv_example_buttonmatrix_3(void)
lv_buttonmatrix_set_map(btnm, map);
lv_obj_add_style(btnm, &style_bg, 0);
lv_obj_add_style(btnm, &style_btn, LV_PART_ITEMS);
lv_obj_add_event(btnm, event_cb, LV_EVENT_VALUE_CHANGED, NULL);
lv_obj_add_event_cb(btnm, event_cb, LV_EVENT_VALUE_CHANGED, NULL);
lv_obj_set_size(btnm, 225, 35);
/*Allow selecting on one number at time*/

View File

@ -49,7 +49,7 @@ buttonm = lv.buttonmatrix(lv.screen_active())
buttonm.set_map(map)
buttonm.add_style(style_bg, 0)
buttonm.add_style(style_button, lv.PART.ITEMS)
buttonm.add_event(event_cb, lv.EVENT.VALUE_CHANGED, None)
buttonm.add_event_cb(event_cb, lv.EVENT.VALUE_CHANGED, None)
buttonm.set_size(225, 35)
# Allow selecting on one number at time

View File

@ -19,7 +19,7 @@ void lv_example_calendar_1(void)
lv_obj_t * calendar = lv_calendar_create(lv_screen_active());
lv_obj_set_size(calendar, 185, 185);
lv_obj_align(calendar, LV_ALIGN_CENTER, 0, 27);
lv_obj_add_event(calendar, event_handler, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(calendar, event_handler, LV_EVENT_ALL, NULL);
lv_calendar_set_today_date(calendar, 2021, 02, 23);
lv_calendar_set_showed_date(calendar, 2021, 02);

View File

@ -13,7 +13,7 @@ def event_handler(e):
calendar = lv.calendar(lv.screen_active())
calendar.set_size(200, 200)
calendar.align(lv.ALIGN.CENTER, 0, 20)
calendar.add_event(event_handler, lv.EVENT.ALL, None)
calendar.add_event_cb(event_handler, lv.EVENT.ALL, None)
calendar.set_today_date(2021, 02, 23)
calendar.set_showed_date(2021, 02)

View File

@ -66,7 +66,7 @@ void lv_example_chart_3(void)
lv_obj_set_size(chart, 200, 150);
lv_obj_center(chart);
lv_obj_add_event(chart, event_cb, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(chart, event_cb, LV_EVENT_ALL, NULL);
lv_obj_refresh_ext_draw_size(chart);
/*Zoom in a little in X*/

View File

@ -33,7 +33,7 @@ void lv_example_chart_4(void)
lv_obj_center(chart);
lv_chart_series_t * ser = lv_chart_add_series(chart, lv_color_hex(0xff0000), LV_CHART_AXIS_PRIMARY_Y);
lv_obj_add_event(chart, draw_event_cb, LV_EVENT_DRAW_TASK_ADDED, NULL);
lv_obj_add_event_cb(chart, draw_event_cb, LV_EVENT_DRAW_TASK_ADDED, NULL);
lv_obj_add_flag(chart, LV_OBJ_FLAG_SEND_DRAW_TASK_EVENTS);
uint32_t i;

View File

@ -65,7 +65,7 @@ chart = lv.chart(lv.screen_active())
chart.set_size(200, 150)
chart.center()
chart.add_event(event_cb, lv.EVENT.ALL, None)
chart.add_event_cb(event_cb, lv.EVENT.ALL, None)
chart.refresh_ext_draw_size()

View File

@ -21,7 +21,7 @@ void lv_example_chart_5(void)
lv_chart_set_div_line_count(chart, 5, 7);
lv_obj_add_event(chart, draw_event_cb, LV_EVENT_DRAW_TASK_ADDED, NULL);
lv_obj_add_event_cb(chart, draw_event_cb, LV_EVENT_DRAW_TASK_ADDED, NULL);
lv_obj_add_flag(chart, LV_OBJ_FLAG_SEND_DRAW_TASK_EVENTS);
lv_chart_series_t * ser = lv_chart_add_series(chart, lv_palette_main(LV_PALETTE_RED), LV_CHART_AXIS_PRIMARY_Y);

View File

@ -28,7 +28,7 @@ void lv_example_chart_6(void)
// lv_chart_set_axis_tick(chart, LV_CHART_AXIS_PRIMARY_Y, 10, 5, 6, 5, true, 40);
// lv_chart_set_axis_tick(chart, LV_CHART_AXIS_PRIMARY_X, 10, 5, 10, 1, true, 30);
lv_obj_add_event(chart, value_changed_event_cb, LV_EVENT_VALUE_CHANGED, NULL);
lv_obj_add_event_cb(chart, value_changed_event_cb, LV_EVENT_VALUE_CHANGED, NULL);
lv_obj_refresh_ext_draw_size(chart);
cursor = lv_chart_add_cursor(chart, lv_palette_main(LV_PALETTE_BLUE), LV_DIR_LEFT | LV_DIR_BOTTOM);

View File

@ -44,7 +44,7 @@ void lv_example_chart_7(void)
lv_obj_t * chart = lv_chart_create(lv_screen_active());
lv_obj_set_size(chart, 200, 150);
lv_obj_align(chart, LV_ALIGN_CENTER, 0, 0);
lv_obj_add_event(chart, draw_event_cb, LV_EVENT_DRAW_TASK_ADDED, NULL);
lv_obj_add_event_cb(chart, draw_event_cb, LV_EVENT_DRAW_TASK_ADDED, NULL);
lv_obj_add_flag(chart, LV_OBJ_FLAG_SEND_DRAW_TASK_EVENTS);
lv_obj_set_style_line_width(chart, 0, LV_PART_ITEMS); /*Remove the lines*/

View File

@ -23,22 +23,22 @@ void lv_example_checkbox_1(void)
lv_obj_t * cb;
cb = lv_checkbox_create(lv_screen_active());
lv_checkbox_set_text(cb, "Apple");
lv_obj_add_event(cb, event_handler, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(cb, event_handler, LV_EVENT_ALL, NULL);
cb = lv_checkbox_create(lv_screen_active());
lv_checkbox_set_text(cb, "Banana");
lv_obj_add_state(cb, LV_STATE_CHECKED);
lv_obj_add_event(cb, event_handler, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(cb, event_handler, LV_EVENT_ALL, NULL);
cb = lv_checkbox_create(lv_screen_active());
lv_checkbox_set_text(cb, "Lemon");
lv_obj_add_state(cb, LV_STATE_DISABLED);
lv_obj_add_event(cb, event_handler, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(cb, event_handler, LV_EVENT_ALL, NULL);
cb = lv_checkbox_create(lv_screen_active());
lv_obj_add_state(cb, LV_STATE_CHECKED | LV_STATE_DISABLED);
lv_checkbox_set_text(cb, "Melon\nand a new line");
lv_obj_add_event(cb, event_handler, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(cb, event_handler, LV_EVENT_ALL, NULL);
lv_obj_update_layout(cb);
}

View File

@ -15,22 +15,22 @@ lv.screen_active().set_flex_align(lv.FLEX_ALIGN.CENTER, lv.FLEX_ALIGN.START, lv.
cb = lv.checkbox(lv.screen_active())
cb.set_text("Apple")
cb.add_event(event_handler, lv.EVENT.ALL, None)
cb.add_event_cb(event_handler, lv.EVENT.ALL, None)
cb = lv.checkbox(lv.screen_active())
cb.set_text("Banana")
cb.add_state(lv.STATE.CHECKED)
cb.add_event(event_handler, lv.EVENT.ALL, None)
cb.add_event_cb(event_handler, lv.EVENT.ALL, None)
cb = lv.checkbox(lv.screen_active())
cb.set_text("Lemon")
cb.add_state(lv.STATE.DISABLED)
cb.add_event(event_handler, lv.EVENT.ALL, None)
cb.add_event_cb(event_handler, lv.EVENT.ALL, None)
cb = lv.checkbox(lv.screen_active())
cb.add_state(lv.STATE.CHECKED | lv.STATE.DISABLED)
cb.set_text("Melon")
cb.add_event(event_handler, lv.EVENT.ALL, None)
cb.add_event_cb(event_handler, lv.EVENT.ALL, None)
cb.update_layout()

View File

@ -55,7 +55,7 @@ void lv_example_checkbox_2(void)
lv_obj_t * cont1 = lv_obj_create(lv_screen_active());
lv_obj_set_flex_flow(cont1, LV_FLEX_FLOW_COLUMN);
lv_obj_set_size(cont1, lv_pct(40), lv_pct(80));
lv_obj_add_event(cont1, radio_event_handler, LV_EVENT_CLICKED, &active_index_1);
lv_obj_add_event_cb(cont1, radio_event_handler, LV_EVENT_CLICKED, &active_index_1);
for(i = 0; i < 5; i++) {
lv_snprintf(buf, sizeof(buf), "A %d", (int)i + 1);
@ -69,7 +69,7 @@ void lv_example_checkbox_2(void)
lv_obj_set_flex_flow(cont2, LV_FLEX_FLOW_COLUMN);
lv_obj_set_size(cont2, lv_pct(40), lv_pct(80));
lv_obj_set_x(cont2, lv_pct(50));
lv_obj_add_event(cont2, radio_event_handler, LV_EVENT_CLICKED, &active_index_2);
lv_obj_add_event_cb(cont2, radio_event_handler, LV_EVENT_CLICKED, &active_index_2);
for(i = 0; i < 3; i++) {
lv_snprintf(buf, sizeof(buf), "B %d", (int)i + 1);

View File

@ -24,7 +24,7 @@ class LV_Example_Checkbox_2:
self.cont1 = lv.obj(lv.screen_active())
self.cont1.set_flex_flow(lv.FLEX_FLOW.COLUMN)
self.cont1.set_size(lv.pct(40), lv.pct(80))
self.cont1.add_event(self.radio_event_handler, lv.EVENT.CLICKED, None)
self.cont1.add_event_cb(self.radio_event_handler, lv.EVENT.CLICKED, None)
for i in range(5):
txt = "A {:d}".format(i+1)
@ -38,7 +38,7 @@ class LV_Example_Checkbox_2:
self.cont2.set_flex_flow(lv.FLEX_FLOW.COLUMN)
self.cont2.set_size(lv.pct(40), lv.pct(80))
self.cont2.set_x(lv.pct(50))
self.cont2.add_event(self.radio_event_handler, lv.EVENT.CLICKED, None)
self.cont2.add_event_cb(self.radio_event_handler, lv.EVENT.CLICKED, None)
for i in range(3):
txt = "B {:d}".format(i+1)

View File

@ -29,7 +29,7 @@ void lv_example_dropdown_1(void)
"Nuts");
lv_obj_align(dd, LV_ALIGN_TOP_MID, 0, 20);
lv_obj_add_event(dd, event_handler, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(dd, event_handler, LV_EVENT_ALL, NULL);
}
#endif

View File

@ -22,5 +22,5 @@ dd.set_options("\n".join([
"Nuts"]))
dd.align(lv.ALIGN.TOP_MID, 0, 20)
dd.add_event(event_handler, lv.EVENT.ALL, None)
dd.add_event_cb(event_handler, lv.EVENT.ALL, None)

View File

@ -37,7 +37,7 @@ void lv_example_dropdown_3(void)
/*In a menu we don't need to show the last clicked item*/
lv_dropdown_set_selected_highlight(dropdown, false);
lv_obj_add_event(dropdown, event_cb, LV_EVENT_VALUE_CHANGED, NULL);
lv_obj_add_event_cb(dropdown, event_cb, LV_EVENT_VALUE_CHANGED, NULL);
}
#endif

View File

@ -42,5 +42,5 @@ dropdown.set_style_transform_rotation(1800, lv.PART.INDICATOR | lv.STATE.CHECKED
# In a menu we don't need to show the last clicked item
dropdown.set_selected_highlight(False)
dropdown.add_event(event_cb, lv.EVENT.VALUE_CHANGED, None)
dropdown.add_event_cb(event_cb, lv.EVENT.VALUE_CHANGED, None)

View File

@ -56,7 +56,7 @@ static lv_obj_t * create_slider(lv_color_t color)
lv_obj_set_size(slider, 10, 200);
lv_obj_set_style_bg_color(slider, color, LV_PART_KNOB);
lv_obj_set_style_bg_color(slider, lv_color_darken(color, LV_OPA_40), LV_PART_INDICATOR);
lv_obj_add_event(slider, slider_event_cb, LV_EVENT_VALUE_CHANGED, NULL);
lv_obj_add_event_cb(slider, slider_event_cb, LV_EVENT_VALUE_CHANGED, NULL);
return slider;
}

View File

@ -22,7 +22,7 @@ def create_slider(color):
slider.set_size(10, 200)
slider.set_style_bg_color(color, lv.PART.KNOB)
slider.set_style_bg_color(color.darken(lv.OPA._40), lv.PART.INDICATOR)
slider.add_event(slider_event_cb, lv.EVENT.VALUE_CHANGED, None)
slider.add_event_cb(slider_event_cb, lv.EVENT.VALUE_CHANGED, None)
return slider
def slider_event_cb(e):

View File

@ -26,13 +26,13 @@ void lv_example_keyboard_1(void)
lv_obj_t * ta;
ta = lv_textarea_create(lv_screen_active());
lv_obj_align(ta, LV_ALIGN_TOP_LEFT, 10, 10);
lv_obj_add_event(ta, ta_event_cb, LV_EVENT_ALL, kb);
lv_obj_add_event_cb(ta, ta_event_cb, LV_EVENT_ALL, kb);
lv_textarea_set_placeholder_text(ta, "Hello");
lv_obj_set_size(ta, 140, 80);
ta = lv_textarea_create(lv_screen_active());
lv_obj_align(ta, LV_ALIGN_TOP_RIGHT, -10, 10);
lv_obj_add_event(ta, ta_event_cb, LV_EVENT_ALL, kb);
lv_obj_add_event_cb(ta, ta_event_cb, LV_EVENT_ALL, kb);
lv_obj_set_size(ta, 140, 80);
lv_keyboard_set_textarea(kb, ta);

View File

@ -16,13 +16,13 @@ kb = lv.keyboard(lv.screen_active())
ta = lv.textarea(lv.screen_active())
ta.set_width(200)
ta.align(lv.ALIGN.TOP_LEFT, 10, 10)
ta.add_event(lambda e: ta_event_cb(e,kb), lv.EVENT.ALL, None)
ta.add_event_cb(lambda e: ta_event_cb(e,kb), lv.EVENT.ALL, None)
ta.set_placeholder_text("Hello")
ta = lv.textarea(lv.screen_active())
ta.set_width(200)
ta.align(lv.ALIGN.TOP_RIGHT, -10, 10)
ta.add_event(lambda e: ta_event_cb(e,kb), lv.EVENT.ALL, None)
ta.add_event_cb(lambda e: ta_event_cb(e,kb), lv.EVENT.ALL, None)
kb.set_textarea(ta)

View File

@ -67,7 +67,7 @@ void lv_example_label_4(void)
lv_obj_set_style_bg_color(grad, lv_color_hex(0xff0000), 0);
lv_obj_set_style_bg_grad_color(grad, lv_color_hex(0x0000ff), 0);
lv_obj_set_style_bg_grad_dir(grad, LV_GRAD_DIR_HOR, 0);
lv_obj_add_event(grad, add_mask_event_cb, LV_EVENT_ALL, mask_map);
lv_obj_add_event_cb(grad, add_mask_event_cb, LV_EVENT_ALL, mask_map);
}
#endif

Some files were not shown because too many files have changed in this diff Show More