Disabling scrolling in textarea

Description

I want to stop the textarea from automatically scrolling when I add text.

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

PSoC 5LP with the PSoC Creator IDE

What do you want to achieve?

I’m receiving text from a UART and appending it to a textarea using lv_ta_add_text. I have a Scroll Up and Scroll Down button that the user can press to scroll through the textarea (when the user presses the buttons, I call lv_page_scroll_ver).

But if the user scrolls up to look at text that was received a while ago, then more text comes in, my call to lv_ta_add_text will cause the textarea to jump back down to the bottom. I would like to disable that, so that if the user is scrolling up and new text comes in, he doesn’t lose his place.

What have you tried so far?

When the user scrolls up and new UART text comes in, I could just hold onto it and not call lv_ta_add_text until the user scrolls back down. But if I do that, scrolling down won’t work smoothly: the user will scroll down line by line to the bottom of the textarea, I’ll add the received text, and the textarea will jump to the end of the received text, which could be many lines. So he was scrolling a line at a time, then suddenly there was a big jump.

Is there any solution to this?

Thank you.

Hi,

there is no API to turn on/off this feature but you can manually revert the position of the scrollable part when a new character is added:


  lv_obj_t * scrl = lv_page_get_scrl(ta);
  lv_coord_t y = lv_obj_get_y(scrl);
  
  ...add chars...
  
  lv_anim_del(scrl, lv_obj_set_y);  /*The new char is focused with an animation*/
  lv_obj_set_y(scrl, y);

Thank you. But won’t LittleVGL see all these changes to the scroll position and think it needs to repaint the display, causing a flicker?

It will really repaint it but won’t flicker because nothing has changed.

If you want you can remove the “auto focus” lv_ta_set_cursor_pos.

You mean find the place in the textarea’s code where it’s calling lv_ta_set_cursor_pos and remove it?

Is there any good solution? I also encountered a similar problem