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

@@ -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

View File

@@ -22,31 +22,31 @@ void lv_example_list_1(void)
lv_obj_t * btn;
lv_list_add_text(list1, "File");
btn = lv_list_add_button(list1, LV_SYMBOL_FILE, "New");
lv_obj_add_event(btn, event_handler, LV_EVENT_CLICKED, NULL);
lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);
btn = lv_list_add_button(list1, LV_SYMBOL_DIRECTORY, "Open");
lv_obj_add_event(btn, event_handler, LV_EVENT_CLICKED, NULL);
lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);
btn = lv_list_add_button(list1, LV_SYMBOL_SAVE, "Save");
lv_obj_add_event(btn, event_handler, LV_EVENT_CLICKED, NULL);
lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);
btn = lv_list_add_button(list1, LV_SYMBOL_CLOSE, "Delete");
lv_obj_add_event(btn, event_handler, LV_EVENT_CLICKED, NULL);
lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);
btn = lv_list_add_button(list1, LV_SYMBOL_EDIT, "Edit");
lv_obj_add_event(btn, event_handler, LV_EVENT_CLICKED, NULL);
lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);
lv_list_add_text(list1, "Connectivity");
btn = lv_list_add_button(list1, LV_SYMBOL_BLUETOOTH, "Bluetooth");
lv_obj_add_event(btn, event_handler, LV_EVENT_CLICKED, NULL);
lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);
btn = lv_list_add_button(list1, LV_SYMBOL_GPS, "Navigation");
lv_obj_add_event(btn, event_handler, LV_EVENT_CLICKED, NULL);
lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);
btn = lv_list_add_button(list1, LV_SYMBOL_USB, "USB");
lv_obj_add_event(btn, event_handler, LV_EVENT_CLICKED, NULL);
lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);
btn = lv_list_add_button(list1, LV_SYMBOL_BATTERY_FULL, "Battery");
lv_obj_add_event(btn, event_handler, LV_EVENT_CLICKED, NULL);
lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);
lv_list_add_text(list1, "Exit");
btn = lv_list_add_button(list1, LV_SYMBOL_OK, "Apply");
lv_obj_add_event(btn, event_handler, LV_EVENT_CLICKED, NULL);
lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);
btn = lv_list_add_button(list1, LV_SYMBOL_CLOSE, "Close");
lv_obj_add_event(btn, event_handler, LV_EVENT_CLICKED, NULL);
lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);
}
#endif

View File

@@ -12,29 +12,29 @@ list1.center()
# Add buttons to the list
list1.add_text("File")
button_new = list1.add_button(lv.SYMBOL.FILE, "New")
button_new.add_event(event_handler,lv.EVENT.ALL, None)
button_new.add_event_cb(event_handler,lv.EVENT.ALL, None)
button_open = list1.add_button(lv.SYMBOL.DIRECTORY, "Open")
button_open.add_event(event_handler,lv.EVENT.ALL, None)
button_open.add_event_cb(event_handler,lv.EVENT.ALL, None)
button_save = list1.add_button(lv.SYMBOL.SAVE, "Save")
button_save.add_event(event_handler,lv.EVENT.ALL, None)
button_save.add_event_cb(event_handler,lv.EVENT.ALL, None)
button_delete = list1.add_button(lv.SYMBOL.CLOSE, "Delete")
button_delete.add_event(event_handler,lv.EVENT.ALL, None)
button_delete.add_event_cb(event_handler,lv.EVENT.ALL, None)
button_edit = list1.add_button(lv.SYMBOL.EDIT, "Edit")
button_edit.add_event(event_handler,lv.EVENT.ALL, None)
button_edit.add_event_cb(event_handler,lv.EVENT.ALL, None)
list1.add_text("Connectivity")
button_bluetooth = list1.add_button(lv.SYMBOL.BLUETOOTH, "Bluetooth")
button_bluetooth.add_event(event_handler,lv.EVENT.ALL, None)
button_bluetooth.add_event_cb(event_handler,lv.EVENT.ALL, None)
button_navig = list1.add_button(lv.SYMBOL.GPS, "Navigation")
button_navig.add_event(event_handler,lv.EVENT.ALL, None)
button_navig.add_event_cb(event_handler,lv.EVENT.ALL, None)
button_USB = list1.add_button(lv.SYMBOL.USB, "USB")
button_USB.add_event(event_handler,lv.EVENT.ALL, None)
button_USB.add_event_cb(event_handler,lv.EVENT.ALL, None)
button_battery = list1.add_button(lv.SYMBOL.BATTERY_FULL, "Battery")
button_battery.add_event(event_handler,lv.EVENT.ALL, None)
button_battery.add_event_cb(event_handler,lv.EVENT.ALL, None)
list1.add_text("Exit")
button_apply = list1.add_button(lv.SYMBOL.OK, "Apply")
button_apply.add_event(event_handler,lv.EVENT.ALL, None)
button_apply.add_event_cb(event_handler,lv.EVENT.ALL, None)
button_close = list1.add_button(lv.SYMBOL.CLOSE, "Close")
button_close.add_event(event_handler,lv.EVENT.ALL, None)
button_close.add_event_cb(event_handler,lv.EVENT.ALL, None)

View File

@@ -124,7 +124,7 @@ void lv_example_list_2(void)
for(i = 0; i < 15; i++) {
btn = lv_button_create(list1);
lv_obj_set_width(btn, lv_pct(50));
lv_obj_add_event(btn, event_handler, LV_EVENT_CLICKED, NULL);
lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);
lv_obj_t * lab = lv_label_create(btn);
lv_label_set_text_fmt(lab, "Item %d", i);
@@ -141,27 +141,27 @@ void lv_example_list_2(void)
lv_obj_set_flex_flow(list2, LV_FLEX_FLOW_COLUMN);
btn = lv_list_add_button(list2, NULL, "Top");
lv_obj_add_event(btn, event_handler_top, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(btn, event_handler_top, LV_EVENT_ALL, NULL);
lv_group_remove_obj(btn);
btn = lv_list_add_button(list2, LV_SYMBOL_UP, "Up");
lv_obj_add_event(btn, event_handler_up, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(btn, event_handler_up, LV_EVENT_ALL, NULL);
lv_group_remove_obj(btn);
btn = lv_list_add_button(list2, LV_SYMBOL_LEFT, "Center");
lv_obj_add_event(btn, event_handler_center, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(btn, event_handler_center, LV_EVENT_ALL, NULL);
lv_group_remove_obj(btn);
btn = lv_list_add_button(list2, LV_SYMBOL_DOWN, "Down");
lv_obj_add_event(btn, event_handler_dn, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(btn, event_handler_dn, LV_EVENT_ALL, NULL);
lv_group_remove_obj(btn);
btn = lv_list_add_button(list2, NULL, "Bottom");
lv_obj_add_event(btn, event_handler_bottom, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(btn, event_handler_bottom, LV_EVENT_ALL, NULL);
lv_group_remove_obj(btn);
btn = lv_list_add_button(list2, LV_SYMBOL_SHUFFLE, "Shuffle");
lv_obj_add_event(btn, event_handler_swap, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(btn, event_handler_swap, LV_EVENT_ALL, NULL);
lv_group_remove_obj(btn);
}

View File

@@ -98,7 +98,7 @@ list1.set_style_pad_row( 5, 0)
for i in range(15):
button = lv.button(list1)
button.set_width(lv.pct(100))
button.add_event( event_handler, lv.EVENT.CLICKED, None)
button.add_event_cb( event_handler, lv.EVENT.CLICKED, None)
lab = lv.label(button)
lab.set_text("Item " + str(i))
@@ -113,25 +113,25 @@ list2.align(lv.ALIGN.TOP_RIGHT, 0, 0)
list2.set_flex_flow(lv.FLEX_FLOW.COLUMN)
button = list2.add_button(None, "Top")
button.add_event(event_handler_top, lv.EVENT.ALL, None)
button.add_event_cb(event_handler_top, lv.EVENT.ALL, None)
lv.group_remove_obj(button)
button = list2.add_button(lv.SYMBOL.UP, "Up")
button.add_event(event_handler_up, lv.EVENT.ALL, None)
button.add_event_cb(event_handler_up, lv.EVENT.ALL, None)
lv.group_remove_obj(button)
button = list2.add_button(lv.SYMBOL.LEFT, "Center")
button.add_event(event_handler_center, lv.EVENT.ALL, None)
button.add_event_cb(event_handler_center, lv.EVENT.ALL, None)
lv.group_remove_obj(button)
button = list2.add_button(lv.SYMBOL.DOWN, "Down")
button.add_event(event_handler_dn, lv.EVENT.ALL, None)
button.add_event_cb(event_handler_dn, lv.EVENT.ALL, None)
lv.group_remove_obj(button)
button = list2.add_button(None, "Bottom")
button.add_event(event_handler_bottom, lv.EVENT.ALL, None)
button.add_event_cb(event_handler_bottom, lv.EVENT.ALL, None)
lv.group_remove_obj(button)
button = list2.add_button(lv.SYMBOL.SHUFFLE, "Shuffle")
button.add_event(event_handler_swap, lv.EVENT.ALL, None)
button.add_event_cb(event_handler_swap, lv.EVENT.ALL, None)
lv.group_remove_obj(button)

View File

@@ -15,29 +15,29 @@ list1.center()
# Add buttons to the list
list1.add_text("File")
button_new = list1.add_button(lv.SYMBOL.FILE, "New")
button_new.add_event(event_handler,lv.EVENT.ALL, None)
button_new.add_event_cb(event_handler,lv.EVENT.ALL, None)
button_open = list1.add_button(lv.SYMBOL.DIRECTORY, "Open")
button_open.add_event(event_handler,lv.EVENT.ALL, None)
button_open.add_event_cb(event_handler,lv.EVENT.ALL, None)
button_save = list1.add_button(lv.SYMBOL.SAVE, "Save")
button_save.add_event(event_handler,lv.EVENT.ALL, None)
button_save.add_event_cb(event_handler,lv.EVENT.ALL, None)
button_delete = list1.add_button(lv.SYMBOL.CLOSE, "Delete")
button_delete.add_event(event_handler,lv.EVENT.ALL, None)
button_delete.add_event_cb(event_handler,lv.EVENT.ALL, None)
button_edit = list1.add_button(lv.SYMBOL.EDIT, "Edit")
button_edit.add_event(event_handler,lv.EVENT.ALL, None)
button_edit.add_event_cb(event_handler,lv.EVENT.ALL, None)
list1.add_text("Connectivity")
button_bluetooth = list1.add_button(lv.SYMBOL.BLUETOOTH, "Bluetooth")
button_bluetooth.add_event(event_handler,lv.EVENT.ALL, None)
button_bluetooth.add_event_cb(event_handler,lv.EVENT.ALL, None)
button_navig = list1.add_button(lv.SYMBOL.GPS, "Navigation")
button_navig.add_event(event_handler,lv.EVENT.ALL, None)
button_navig.add_event_cb(event_handler,lv.EVENT.ALL, None)
button_USB = list1.add_button(lv.SYMBOL.USB, "USB")
button_USB.add_event(event_handler,lv.EVENT.ALL, None)
button_USB.add_event_cb(event_handler,lv.EVENT.ALL, None)
button_battery = list1.add_button(lv.SYMBOL.BATTERY_FULL, "Battery")
button_battery.add_event(event_handler,lv.EVENT.ALL, None)
button_battery.add_event_cb(event_handler,lv.EVENT.ALL, None)
list1.add_text("Exit")
button_apply = list1.add_button(lv.SYMBOL.OK, "Apply")
button_apply.add_event(event_handler,lv.EVENT.ALL, None)
button_apply.add_event_cb(event_handler,lv.EVENT.ALL, None)
button_close = list1.add_button(lv.SYMBOL.CLOSE, "Close")
button_close.add_event(event_handler,lv.EVENT.ALL, None)
button_close.add_event_cb(event_handler,lv.EVENT.ALL, None)

View File

@@ -16,7 +16,7 @@ void lv_example_menu_2(void)
{
lv_obj_t * menu = lv_menu_create(lv_screen_active());
lv_menu_set_mode_root_back_button(menu, LV_MENU_ROOT_BACK_BUTTON_ENABLED);
lv_obj_add_event(menu, back_event_handler, LV_EVENT_CLICKED, menu);
lv_obj_add_event_cb(menu, back_event_handler, LV_EVENT_CLICKED, menu);
lv_obj_set_size(menu, lv_display_get_horizontal_resolution(NULL), lv_display_get_vertical_resolution(NULL));
lv_obj_center(menu);

View File

@@ -7,7 +7,7 @@ def back_event_handler(e):
# Create a menu object
menu = lv.menu(lv.screen_active())
menu.set_mode_root_back_button(lv.menu.ROOT_BACK_BUTTON.ENABLED)
menu.add_event(back_event_handler, lv.EVENT.CLICKED, None)
menu.add_event_cb(back_event_handler, lv.EVENT.CLICKED, None)
menu.set_size(320, 240)
menu.center()

View File

@@ -60,7 +60,7 @@ void lv_example_menu_4(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, -10, -10);
lv_obj_add_event(float_btn, float_button_event_cb, LV_EVENT_CLICKED, menu);
lv_obj_add_event_cb(float_btn, float_button_event_cb, LV_EVENT_CLICKED, menu);
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

@@ -41,7 +41,7 @@ float_button = lv.button(lv.screen_active())
float_button.set_size(50, 50)
float_button.add_flag(lv.obj.FLAG.FLOATING)
float_button.align(lv.ALIGN.BOTTOM_RIGHT, -10, -10)
float_button.add_event(float_button_event_cb, lv.EVENT.CLICKED, None)
float_button.add_event_cb(float_button_event_cb, lv.EVENT.CLICKED, 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

@@ -29,7 +29,7 @@ void lv_example_menu_5(void)
lv_obj_set_style_bg_color(menu, lv_color_darken(lv_obj_get_style_bg_color(menu, 0), 50), 0);
}
lv_menu_set_mode_root_back_button(menu, LV_MENU_ROOT_BACK_BUTTON_ENABLED);
lv_obj_add_event(menu, back_event_handler, LV_EVENT_CLICKED, menu);
lv_obj_add_event_cb(menu, back_event_handler, LV_EVENT_CLICKED, menu);
lv_obj_set_size(menu, lv_display_get_horizontal_resolution(NULL), lv_display_get_vertical_resolution(NULL));
lv_obj_center(menu);
@@ -85,7 +85,7 @@ void lv_example_menu_5(void)
lv_menu_separator_create(sub_menu_mode_page);
section = lv_menu_section_create(sub_menu_mode_page);
cont = create_switch(section, LV_SYMBOL_AUDIO, "Sidebar enable", true);
lv_obj_add_event(lv_obj_get_child(cont, 2), switch_handler, LV_EVENT_VALUE_CHANGED, menu);
lv_obj_add_event_cb(lv_obj_get_child(cont, 2), switch_handler, LV_EVENT_VALUE_CHANGED, menu);
/*Create a root page*/
root_page = lv_menu_page_create(menu, "Settings");

View File

@@ -87,7 +87,7 @@ else :
menu.set_mode_root_back_button(lv.menu.ROOT_BACK_BUTTON.ENABLED)
menu.add_event(lambda evt: back_event_handler(evt,menu), lv.EVENT.CLICKED, None)
menu.add_event_cb(lambda evt: back_event_handler(evt,menu), lv.EVENT.CLICKED, None)
menu.set_size(lv.pct(100), lv.pct(100))
menu.center()
@@ -142,7 +142,7 @@ sub_menu_mode_page.set_style_pad_hor(menu.get_main_header().get_style_pad_left(0
lv.menu_separator(sub_menu_mode_page)
section = lv.menu_section(sub_menu_mode_page)
cont = create_switch(section, lv.SYMBOL.AUDIO, "Sidebar enable",True)
cont.get_child(2).add_event(lambda evt: switch_handler(evt,menu), lv.EVENT.VALUE_CHANGED, None)
cont.get_child(2).add_event_cb(lambda evt: switch_handler(evt,menu), lv.EVENT.VALUE_CHANGED, None)
# Create a root page
root_page = lv.menu_page(menu, "Settings")

View File

@@ -13,7 +13,7 @@ void lv_example_msgbox_1(void)
static const char * buttons[] = {"Apply", "Close", ""};
lv_obj_t * mbox1 = lv_msgbox_create(NULL, "Hello", "This is a message box with two buttons.", buttons, true);
lv_obj_add_event(mbox1, event_cb, LV_EVENT_VALUE_CHANGED, NULL);
lv_obj_add_event_cb(mbox1, event_cb, LV_EVENT_VALUE_CHANGED, NULL);
lv_obj_center(mbox1);
}

View File

@@ -5,6 +5,6 @@ def event_cb(e):
buttons = ["Apply", "Close", ""]
mbox1 = lv.msgbox(lv.screen_active(), "Hello", "This is a message box with two buttons.", buttons, True)
mbox1.add_event(event_cb, lv.EVENT.VALUE_CHANGED, None)
mbox1.add_event_cb(event_cb, lv.EVENT.VALUE_CHANGED, None)
mbox1.center()

View File

@@ -24,7 +24,7 @@ void lv_example_obj_2(void)
lv_obj_t * obj;
obj = lv_obj_create(lv_screen_active());
lv_obj_set_size(obj, 150, 100);
lv_obj_add_event(obj, drag_event_handler, LV_EVENT_PRESSING, NULL);
lv_obj_add_event_cb(obj, drag_event_handler, LV_EVENT_PRESSING, NULL);
lv_obj_t * label = lv_label_create(obj);
lv_label_set_text(label, "Drag me");

View File

@@ -17,7 +17,7 @@ def drag_event_handler(e):
obj = lv.obj(lv.screen_active())
obj.set_size(150, 100)
obj.add_event(drag_event_handler, lv.EVENT.PRESSING, None)
obj.add_event_cb(drag_event_handler, lv.EVENT.PRESSING, None)
label = lv.label(obj)
label.set_text("Drag me")

View File

@@ -35,7 +35,7 @@ void lv_example_roller_1(void)
lv_roller_set_visible_row_count(roller1, 4);
lv_obj_center(roller1);
lv_obj_add_event(roller1, event_handler, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(roller1, event_handler, LV_EVENT_ALL, NULL);
}
#endif

View File

@@ -27,5 +27,5 @@ roller1.set_options("\n".join([
roller1.set_visible_row_count(4)
roller1.center()
roller1.add_event(event_handler, lv.EVENT.ALL, None)
roller1.add_event_cb(event_handler, lv.EVENT.ALL, None)

View File

@@ -39,7 +39,7 @@ void lv_example_roller_2(void)
lv_obj_set_style_bg_grad_color(roller, lv_color_hex3(0xafa), 0);
lv_obj_set_style_bg_grad_dir(roller, LV_GRAD_DIR_VER, 0);
lv_obj_align(roller, LV_ALIGN_LEFT_MID, 10, 0);
lv_obj_add_event(roller, event_handler, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(roller, event_handler, LV_EVENT_ALL, NULL);
lv_roller_set_selected(roller, 2, LV_ANIM_OFF);
/*A roller on the middle with center aligned text, and auto (default) width*/
@@ -48,7 +48,7 @@ void lv_example_roller_2(void)
lv_roller_set_visible_row_count(roller, 3);
lv_obj_add_style(roller, &style_sel, LV_PART_SELECTED);
lv_obj_align(roller, LV_ALIGN_CENTER, 0, 0);
lv_obj_add_event(roller, event_handler, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(roller, event_handler, LV_EVENT_ALL, NULL);
lv_roller_set_selected(roller, 5, LV_ANIM_OFF);
/*A roller on the right with right aligned text, and custom width*/
@@ -59,7 +59,7 @@ void lv_example_roller_2(void)
lv_obj_add_style(roller, &style_sel, LV_PART_SELECTED);
lv_obj_set_style_text_align(roller, LV_TEXT_ALIGN_RIGHT, 0);
lv_obj_align(roller, LV_ALIGN_RIGHT_MID, -10, 0);
lv_obj_add_event(roller, event_handler, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(roller, event_handler, LV_EVENT_ALL, NULL);
lv_roller_set_selected(roller, 8, LV_ANIM_OFF);
}

View File

@@ -52,7 +52,7 @@ roller.set_style_text_align(lv.TEXT_ALIGN.LEFT, 0)
roller.set_style_bg_color(lv.color_hex3(0x0f0), 0)
roller.set_style_bg_grad_color(lv.color_hex3(0xafa), 0);
roller.align(lv.ALIGN.LEFT_MID, 10, 0)
roller.add_event(event_handler, lv.EVENT.ALL, None)
roller.add_event_cb(event_handler, lv.EVENT.ALL, None)
roller.set_selected(2, lv.ANIM.OFF)
# A roller in the middle with center aligned text, and auto (default) width
@@ -61,7 +61,7 @@ roller.set_options(opts, lv.roller.MODE.NORMAL)
roller.set_visible_row_count(3)
roller.add_style(style_sel, lv.PART.SELECTED)
roller.align(lv.ALIGN.CENTER, 0, 0)
roller.add_event(event_handler, lv.EVENT.ALL, None)
roller.add_event_cb(event_handler, lv.EVENT.ALL, None)
roller.set_selected(5, lv.ANIM.OFF)
# A roller on the right with right aligned text, and custom width
@@ -72,5 +72,5 @@ roller.set_width(80)
roller.add_style(style_sel, lv.PART.SELECTED)
roller.set_style_text_align(lv.TEXT_ALIGN.RIGHT, 0)
roller.align(lv.ALIGN.RIGHT_MID, -10, 0)
roller.add_event(event_handler, lv.EVENT.ALL, None)
roller.add_event_cb(event_handler, lv.EVENT.ALL, None)
roller.set_selected(8, lv.ANIM.OFF)

View File

@@ -91,6 +91,6 @@ void lv_example_roller_3(void)
lv_obj_center(roller1);
lv_roller_set_visible_row_count(roller1, 3);
lv_obj_add_event(roller1, mask_event_cb, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(roller1, mask_event_cb, LV_EVENT_ALL, NULL);
}
#endif

View File

@@ -12,7 +12,7 @@ void lv_example_slider_1(void)
/*Create a slider in the center of the display*/
lv_obj_t * slider = lv_slider_create(lv_screen_active());
lv_obj_center(slider);
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_obj_set_style_anim_time(slider, 2000, 0);
/*Create a label below the slider*/

View File

@@ -10,7 +10,7 @@ def slider_event_cb(e):
# Create a slider in the center of the display
slider = lv.slider(lv.screen_active())
slider.center()
slider.add_event(slider_event_cb, lv.EVENT.VALUE_CHANGED, None)
slider.add_event_cb(slider_event_cb, lv.EVENT.VALUE_CHANGED, None)
# Create a label below the slider
slider_label = lv.label(lv.screen_active())

View File

@@ -18,7 +18,7 @@ void lv_example_slider_3(void)
lv_slider_set_value(slider, 70, LV_ANIM_OFF);
lv_slider_set_left_value(slider, 20, LV_ANIM_OFF);
lv_obj_add_event(slider, slider_event_cb, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(slider, slider_event_cb, LV_EVENT_ALL, NULL);
lv_obj_refresh_ext_draw_size(slider);
}

View File

@@ -39,7 +39,7 @@ slider.set_mode(lv.slider.MODE.RANGE)
slider.set_value(70, lv.ANIM.OFF)
slider.set_left_value(20, lv.ANIM.OFF)
slider.add_event(slider_event_cb, lv.EVENT.ALL, None)
slider.add_event_cb(slider_event_cb, lv.EVENT.ALL, None)
slider.add_flag(lv.obj.FLAG.SEND_DRAW_TASK_EVENTS)
slider.refresh_ext_draw_size()

View File

@@ -12,7 +12,7 @@ void lv_example_slider_4(void)
/*Create a slider in the center of the display*/
lv_obj_t * slider = lv_slider_create(lv_screen_active());
lv_obj_center(slider);
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);
/*Reverse the direction of the slider*/
lv_slider_set_range(slider, 100, 0);
/*Create a label below the slider*/

View File

@@ -10,7 +10,7 @@ def slider_event_cb(e):
# Create a slider in the center of the display
slider = lv.slider(lv.screen_active())
slider.center()
slider.add_event(slider_event_cb, lv.EVENT.VALUE_CHANGED, None)
slider.add_event_cb(slider_event_cb, lv.EVENT.VALUE_CHANGED, None)
slider.set_range(100, 0)
# Create a label below the slider

View File

@@ -34,13 +34,13 @@ void lv_example_spinbox_1(void)
lv_obj_set_size(btn, h, h);
lv_obj_align_to(btn, spinbox, LV_ALIGN_OUT_RIGHT_MID, 5, 0);
lv_obj_set_style_bg_image_src(btn, LV_SYMBOL_PLUS, 0);
lv_obj_add_event(btn, lv_spinbox_increment_event_cb, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(btn, lv_spinbox_increment_event_cb, LV_EVENT_ALL, NULL);
btn = lv_button_create(lv_screen_active());
lv_obj_set_size(btn, h, h);
lv_obj_align_to(btn, spinbox, LV_ALIGN_OUT_LEFT_MID, -5, 0);
lv_obj_set_style_bg_image_src(btn, LV_SYMBOL_MINUS, 0);
lv_obj_add_event(btn, lv_spinbox_decrement_event_cb, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(btn, lv_spinbox_decrement_event_cb, LV_EVENT_ALL, NULL);
}
#endif

View File

@@ -21,10 +21,10 @@ button = lv.button(lv.screen_active())
button.set_size(h, h)
button.align_to(spinbox, lv.ALIGN.OUT_RIGHT_MID, 5, 0)
button.set_style_bg_image_src(lv.SYMBOL.PLUS, 0)
button.add_event(increment_event_cb, lv.EVENT.ALL, None)
button.add_event_cb(increment_event_cb, lv.EVENT.ALL, None)
button = lv.button(lv.screen_active())
button.set_size(h, h)
button.align_to(spinbox, lv.ALIGN.OUT_LEFT_MID, -5, 0)
button.set_style_bg_image_src(lv.SYMBOL.MINUS, 0)
button.add_event(decrement_event_cb, lv.EVENT.ALL, None)
button.add_event_cb(decrement_event_cb, lv.EVENT.ALL, None)

View File

@@ -19,20 +19,20 @@ void lv_example_switch_1(void)
lv_obj_t * sw;
sw = lv_switch_create(lv_screen_active());
lv_obj_add_event(sw, event_handler, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(sw, event_handler, LV_EVENT_ALL, NULL);
lv_obj_add_flag(sw, LV_OBJ_FLAG_EVENT_BUBBLE);
sw = lv_switch_create(lv_screen_active());
lv_obj_add_state(sw, LV_STATE_CHECKED);
lv_obj_add_event(sw, event_handler, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(sw, event_handler, LV_EVENT_ALL, NULL);
sw = lv_switch_create(lv_screen_active());
lv_obj_add_state(sw, LV_STATE_DISABLED);
lv_obj_add_event(sw, event_handler, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(sw, event_handler, LV_EVENT_ALL, NULL);
sw = lv_switch_create(lv_screen_active());
lv_obj_add_state(sw, LV_STATE_CHECKED | LV_STATE_DISABLED);
lv_obj_add_event(sw, event_handler, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(sw, event_handler, LV_EVENT_ALL, NULL);
}
#endif

View File

@@ -9,18 +9,18 @@ lv.screen_active().set_flex_flow(lv.FLEX_FLOW.COLUMN)
lv.screen_active().set_flex_align(lv.FLEX_ALIGN.CENTER, lv.FLEX_ALIGN.CENTER, lv.FLEX_ALIGN.CENTER)
sw = lv.switch(lv.screen_active())
sw.add_event(event_handler, lv.EVENT.ALL, None)
sw.add_event_cb(event_handler, lv.EVENT.ALL, None)
sw.add_flag(lv.obj.FLAG.EVENT_BUBBLE)
sw = lv.switch(lv.screen_active())
sw.add_state(lv.STATE.CHECKED)
sw.add_event(event_handler, lv.EVENT.ALL, None)
sw.add_event_cb(event_handler, lv.EVENT.ALL, None)
sw = lv.switch(lv.screen_active())
sw.add_state(lv.STATE.DISABLED)
sw.add_event(event_handler, lv.EVENT.ALL, None)
sw.add_event_cb(event_handler, lv.EVENT.ALL, None)
sw = lv.switch(lv.screen_active())
sw.add_state(lv.STATE.CHECKED | lv.STATE.DISABLED)
sw.add_event(event_handler, lv.EVENT.ALL, None)
sw.add_event_cb(event_handler, lv.EVENT.ALL, None)

View File

@@ -70,7 +70,7 @@ void lv_example_table_1(void)
lv_obj_center(table);
/*Add an event callback to to apply some custom drawing*/
lv_obj_add_event(table, draw_event_cb, LV_EVENT_DRAW_TASK_ADDED, NULL);
lv_obj_add_event_cb(table, draw_event_cb, LV_EVENT_DRAW_TASK_ADDED, NULL);
lv_obj_add_flag(table, LV_OBJ_FLAG_SEND_DRAW_TASK_EVENTS);
}

View File

@@ -85,8 +85,8 @@ void lv_example_table_2(void)
lv_obj_align(table, LV_ALIGN_CENTER, 0, -20);
/*Add an event callback to to apply some custom drawing*/
lv_obj_add_event(table, draw_event_cb, LV_EVENT_DRAW_TASK_ADDED, NULL);
lv_obj_add_event(table, change_event_cb, LV_EVENT_VALUE_CHANGED, NULL);
lv_obj_add_event_cb(table, draw_event_cb, LV_EVENT_DRAW_TASK_ADDED, NULL);
lv_obj_add_event_cb(table, change_event_cb, LV_EVENT_VALUE_CHANGED, NULL);
lv_obj_add_flag(table, LV_OBJ_FLAG_SEND_DRAW_TASK_EVENTS);
lv_mem_monitor_t mon2;

View File

@@ -25,7 +25,7 @@ void lv_example_textarea_1(void)
lv_obj_t * ta = lv_textarea_create(lv_screen_active());
lv_textarea_set_one_line(ta, true);
lv_obj_align(ta, LV_ALIGN_TOP_MID, 0, 10);
lv_obj_add_event(ta, textarea_event_handler, LV_EVENT_READY, ta);
lv_obj_add_event_cb(ta, textarea_event_handler, LV_EVENT_READY, ta);
lv_obj_add_state(ta, LV_STATE_FOCUSED); /*To be sure the cursor is visible*/
static const char * btnm_map[] = {"1", "2", "3", "\n",
@@ -37,7 +37,7 @@ void lv_example_textarea_1(void)
lv_obj_t * btnm = lv_buttonmatrix_create(lv_screen_active());
lv_obj_set_size(btnm, 200, 150);
lv_obj_align(btnm, LV_ALIGN_BOTTOM_MID, 0, -10);
lv_obj_add_event(btnm, btnm_event_handler, LV_EVENT_VALUE_CHANGED, ta);
lv_obj_add_event_cb(btnm, btnm_event_handler, LV_EVENT_VALUE_CHANGED, ta);
lv_obj_remove_flag(btnm, LV_OBJ_FLAG_CLICK_FOCUSABLE); /*To keep the text area focused on button clicks*/
lv_buttonmatrix_set_map(btnm, btnm_map);
}

View File

@@ -16,7 +16,7 @@ def buttonm_event_handler(e, ta):
ta = lv.textarea(lv.screen_active())
ta.set_one_line(True)
ta.align(lv.ALIGN.TOP_MID, 0, 10)
ta.add_event(lambda e: textarea_event_handler(e, ta), lv.EVENT.READY, None)
ta.add_event_cb(lambda e: textarea_event_handler(e, ta), lv.EVENT.READY, None)
ta.add_state(lv.STATE.FOCUSED) # To be sure the cursor is visible
buttonm_map = ["1", "2", "3", "\n",
@@ -27,6 +27,6 @@ buttonm_map = ["1", "2", "3", "\n",
buttonm = lv.buttonmatrix(lv.screen_active())
buttonm.set_size(200, 150)
buttonm.align(lv.ALIGN.BOTTOM_MID, 0, -10)
buttonm.add_event(lambda e: buttonm_event_handler(e, ta), lv.EVENT.VALUE_CHANGED, None)
buttonm.add_event_cb(lambda e: buttonm_event_handler(e, ta), lv.EVENT.VALUE_CHANGED, None)
buttonm.remove_flag(lv.obj.FLAG.CLICK_FOCUSABLE) # To keep the text area focused on button clicks
buttonm.set_map(buttonm_map)

View File

@@ -14,7 +14,7 @@ void lv_example_textarea_2(void)
lv_textarea_set_one_line(pwd_ta, true);
lv_obj_set_width(pwd_ta, lv_pct(40));
lv_obj_set_pos(pwd_ta, 5, 20);
lv_obj_add_event(pwd_ta, ta_event_cb, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(pwd_ta, ta_event_cb, LV_EVENT_ALL, NULL);
/*Create a label and position it above the text box*/
lv_obj_t * pwd_label = lv_label_create(lv_screen_active());
@@ -26,7 +26,7 @@ void lv_example_textarea_2(void)
lv_textarea_set_one_line(text_ta, true);
lv_textarea_set_password_mode(text_ta, false);
lv_obj_set_width(text_ta, lv_pct(40));
lv_obj_add_event(text_ta, ta_event_cb, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(text_ta, ta_event_cb, LV_EVENT_ALL, NULL);
lv_obj_align(text_ta, LV_ALIGN_TOP_RIGHT, -5, 20);
/*Create a label and position it above the text box*/

View File

@@ -18,7 +18,7 @@ pwd_ta.set_password_mode(True)
pwd_ta.set_one_line(True)
pwd_ta.set_width(lv.pct(45))
pwd_ta.set_pos(5, 20)
pwd_ta.add_event(ta_event_cb, lv.EVENT.ALL, None)
pwd_ta.add_event_cb(ta_event_cb, lv.EVENT.ALL, None)
# Create a label and position it above the text box
pwd_label = lv.label(lv.screen_active())
@@ -29,7 +29,7 @@ pwd_label.align_to(pwd_ta, lv.ALIGN.OUT_TOP_LEFT, 0, 0)
text_ta = lv.textarea(lv.screen_active())
text_ta.set_width(lv.pct(45))
text_ta.set_one_line(True)
text_ta.add_event(ta_event_cb, lv.EVENT.ALL, None)
text_ta.add_event_cb(ta_event_cb, lv.EVENT.ALL, None)
text_ta.set_password_mode(False)
text_ta.align(lv.ALIGN.TOP_RIGHT, -5, 20)

View File

@@ -13,7 +13,7 @@ void lv_example_textarea_3(void)
{
/*Create the text area*/
lv_obj_t * ta = lv_textarea_create(lv_screen_active());
lv_obj_add_event(ta, ta_event_cb, LV_EVENT_VALUE_CHANGED, NULL);
lv_obj_add_event_cb(ta, ta_event_cb, LV_EVENT_VALUE_CHANGED, NULL);
lv_textarea_set_accepted_chars(ta, "0123456789:");
lv_textarea_set_max_length(ta, 5);
lv_textarea_set_one_line(ta, true);

View File

@@ -31,7 +31,7 @@ def ta_event_cb(e):
# Create the text area
ta = lv.textarea(lv.screen_active())
ta.add_event(ta_event_cb, lv.EVENT.VALUE_CHANGED, None)
ta.add_event_cb(ta_event_cb, lv.EVENT.VALUE_CHANGED, None)
ta.set_accepted_chars("0123456789:")
ta.set_max_length(5)
ta.set_one_line(True)

View File

@@ -13,15 +13,15 @@ void lv_example_win_1(void)
lv_obj_t * win = lv_win_create(lv_screen_active());
lv_obj_t * btn;
btn = lv_win_add_button(win, LV_SYMBOL_LEFT, 40);
lv_obj_add_event(btn, event_handler, LV_EVENT_CLICKED, NULL);
lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);
lv_win_add_title(win, "A title");
btn = lv_win_add_button(win, LV_SYMBOL_RIGHT, 40);
lv_obj_add_event(btn, event_handler, LV_EVENT_CLICKED, NULL);
lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);
btn = lv_win_add_button(win, LV_SYMBOL_CLOSE, 60);
lv_obj_add_event(btn, event_handler, LV_EVENT_CLICKED, NULL);
lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);
lv_obj_t * cont = lv_win_get_content(win); /*Content can be added here*/
lv_obj_t * label = lv_label_create(cont);

View File

@@ -7,12 +7,12 @@ def event_handler(e):
win = lv.win(lv.screen_active())
button1 = win.add_button(lv.SYMBOL.LEFT, 40)
button1.add_event(event_handler, lv.EVENT.ALL, None)
button1.add_event_cb(event_handler, lv.EVENT.ALL, None)
win.add_title("A title")
button2=win.add_button(lv.SYMBOL.RIGHT, 40)
button2.add_event(event_handler, lv.EVENT.ALL, None)
button2.add_event_cb(event_handler, lv.EVENT.ALL, None)
button3 = win.add_button(lv.SYMBOL.CLOSE, 60)
button3.add_event(event_handler, lv.EVENT.ALL, None)
button3.add_event_cb(event_handler, lv.EVENT.ALL, None)
cont = win.get_content() # Content can be added here
label = lv.label(cont)