How to disable elastic scroll?


  1. How to disable elastic scroll?
	lv_obj_t * cont_val = lv_obj_create(lv_scr_act());
	lv_obj_set_size(cont_val, 480, 320);
	lv_obj_set_scrollbar_mode(cont_val, LV_SCROLLBAR_MODE_OFF);

	lv_obj_t * label_title = lv_label_create(cont_val);
	lv_label_set_text(label_title, CURR_DSP_TITLE);
	lv_obj_set_style_text_font(label_title, &lv_font_montserrat_20, LV_PART_MAIN | LV_STATE_DEFAULT);
	lv_obj_align_to(label_title, cont_val, LV_ALIGN_TOP_LEFT, 5, -10);

	ta1 = lv_textarea_create(cont_val);
	lv_obj_add_event_cb(ta1, ta1_event_cb, LV_EVENT_CLICKED, NULL);
	lv_obj_set_size(ta1, 300, 100);
    lv_obj_add_style(ta1, &style_ta, 0);
    lv_obj_align_to(ta1, cont_val, LV_ALIGN_TOP_LEFT, 5, 13);
    lv_textarea_set_text(ta1, val);  
    lv_textarea_t * ta = (lv_textarea_t *)ta1;
    ta-> = 1;

    lv_obj_set_scrollbar_mode(ta1, LV_SCROLLBAR_MODE_OFF);

    lv_textarea_set_align(ta1, LV_TEXT_ALIGN_CENTER);
    lv_textarea_set_max_length(ta1, 5);

    lv_obj_t * label_unit = lv_label_create(cont_val);
    lv_obj_set_size(label_unit, 120, 80);
//    lv_label_set_text(label_unit, fixed_unit[CURR_DSP_UNIT]);
    lv_label_set_text(label_unit, "nanog/kg/min");
    lv_obj_align_to(label_unit, ta1, LV_ALIGN_OUT_RIGHT_MID, 0, 0);
    lv_obj_set_style_text_font(label_unit, &lv_font_montserrat_28, LV_PART_MAIN | LV_STATE_DEFAULT);

	kb = lv_keyboard_create(cont_val);
	lv_obj_add_event_cb(kb, kb_event_cb, LV_EVENT_CLICKED, NULL);
    lv_obj_set_size(kb, 479, 200);
    lv_obj_add_style(kb, &style_kb, 0);
	lv_btnmatrix_set_map(kb, btnm_map);
    lv_keyboard_set_textarea(kb, ta1);
//    lv_obj_set_align(kb, LV_ALIGN_BOTTOM_MID);
    lv_obj_align_to(kb, cont_val, LV_ALIGN_BOTTOM_MID, 10, 10);

The below code didn’t work.
2. How to show cursor in text area?

 ta1 = lv_textarea_create(cont_val);
 lv_textarea_t * ta = (lv_textarea_t *)ta1;
 ta-> = 1;

What MCU/Processor/Board and compiler are you using?

What LVGL version are you using?

What do you want to achieve?

What have you tried so far?

Code to reproduce

Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.

The code block(s) should be formatted like:

/*You code here*/

Screenshot and/or video

If possible, add screenshots and/or videos about the current state.

how can I disable elastic scroll selectively?
I can disable elastic scroll by commenting it in lv_obj_constructor() function, but it can’t use everywhere.

static void lv_obj_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj)

    lv_obj_t * parent = obj->parent;
    if(parent) {
        lv_coord_t sl = lv_obj_get_scroll_left(parent);
        lv_coord_t st = lv_obj_get_scroll_top(parent);

        obj->coords.y1 = parent->coords.y1 + lv_obj_get_style_pad_top(parent, LV_PART_MAIN) - st;
        obj->coords.y2 = obj->coords.y1 - 1;
        obj->coords.x1  = parent->coords.x1 + lv_obj_get_style_pad_left(parent, LV_PART_MAIN) - sl;
        obj->coords.x2  = obj->coords.x1 - 1;

    /*Set attributes*/
    obj->flags = LV_OBJ_FLAG_CLICKABLE;
    obj->flags |= LV_OBJ_FLAG_SNAPPABLE;
    if(parent) obj->flags |= LV_OBJ_FLAG_PRESS_LOCK;
    if(parent) obj->flags |= LV_OBJ_FLAG_SCROLL_CHAIN;
    obj->flags |= LV_OBJ_FLAG_CLICK_FOCUSABLE;
    obj->flags |= LV_OBJ_FLAG_SCROLLABLE;
//    obj->flags |= LV_OBJ_FLAG_SCROLL_ELASTIC;
    obj->flags |= LV_OBJ_FLAG_SCROLL_MOMENTUM;
    if(parent) obj->flags |= LV_OBJ_FLAG_GESTURE_BUBBLE;


Try this way:

  lv_obj_clear_flag(obj, LV_OBJ_FLAG_SCROLL_ELASTIC);

In my experience:
1.the container(parent) must large enough. E.g. If the height of object is H, and the pad is h, the height of container must larger than H+2h.
2.Set the pad of the container as zero via
lv_obj_set_style_pad_top(cont, 0, LV_STATE_DEFAULT);