How do we get the text area to track the cursor?


I have a text area (single line mode) and I add characters
to it using lv_textarea_add_char(). When characters overflow
the display part or the text area, characters are properly added but the
text area doesn’t scroll automatically to show the last characters.

My display is not a touch screen, so I can’t see these

Essentially, I need the text area to track the position of the cursor.
If the cursor is at the end of the string, the text area should
have scrolled appropriately to show the last characters at the
end of the text area display. Conversely, if the cursor is moved
to the start of the string, the text area should scroll to the
beginning of the string.

This can easily be replicated with the “Simple Text Area” demo in

Just run the C lv_example_textarea_1() demo app

Strangely enough, the Ptyhon version works as expected but the
C version does not.

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

Using a custom board based on DSPG products.
Can also be easily replicated with Linux SDL

What LVGL version are you using?

Version 8.1

What do you want to achieve?

As described above

What have you tried so far?

Code to reproduce

Use the lv_example_textarea_1() demo application without any changes.

Screenshot and/or video

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

Can’t reproduce using the live example; is that what you meant by the Python version working as expected? The live example is using C.

Ok. I tried the simulator (python) and not web page live demo (which also works as you stated).

However, running the code on Linux simulator (with SDL) does not behave as expected. (When the text area fills up, the horizontal scroll bar appears but we never see the last entered digits)
Also running the code on my device (DSPG board) using /dev/fb, does not work either (same behavior as Linux).

This is what I see before and after I enter “123456789” (as individual chars). Scroll bar appears but it doesn’t scroll to the last digits (as in the web example)

(cc @kisvegabor)

I was able to reproduce this on the release/v8.0 branch, but not the master branch, so this should be fixed when 8.0.2 is released.

I’ve fixed it 8 days ago here: fix(textarea) style update in oneline mode + improve sroll to cursor · lvgl/lvgl@60d9a5e · GitHub

I’d like to create a release script before releasing v8.0.2. BTW, @embeddedt is there any news about automatic changelog generation?

I ran into the same issue as you where it was outputting blank files for 8.0.1. The documentation on how it works was not the greatest, so I had given up on it for the time being. I can try it again and see if 8.0.2 will be better behaved.

Thanks Gabor. I’ve tested the latest code and it now works as expected. Much appreciated.