refactor(event): add _cb postfix to lv_obj_add_event()
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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*/
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user