2024-06-24 07:11 AM
Hi,
how do you implement a scrollable text box? i.e. a text box where the text is too long to display in the available area so the user needs to scroll down like in a mobile phone?
Is this done fully by TouchGFX or do I need to write a lot of code behind it to do the display and the scrolling?
Thank you :)
Solved! Go to Solution.
2024-06-25 01:19 AM
My pleasure!
1) the scrolling functionality (i.e. the code for the scrolling) is generated by the TouchGFX (or other tool) or if I need to write additional code
TouchGFX Generates codes based on the design you create in Designer.
The generated code can be found in the folder "generated" => "gui_generated". Those files are call xxxxxxxxBase.cpp/hpp, ex: screen1ViewBase.cpp. You should never modify these files as they get regenerated (erasing your changes) every time you click on "Generate code" in Designer.
It also creates a bunch of other files and folders. The one that matter to you are in the folder "gui", ex: screen1View.cpp (which you can modify).
In the example I made (were you able to look at the example I provided, the file with 7z extension?) the whole design inside Designer and did not code a single thing.
However, if you want to fetch the length of the textArea and set the length of the scrollable container accordingly, you would have to write some simple code in screen1View.cpp.
2) if, to do the entire scrollable text box with fixed text inside it that can be scrolled - whether like you suggested or any other way - is a few hours job or a week long job. Again this is for someone who has written a lot of C but never used UI or touch displays, let alone TouchGFX.
Well, it depends on you. Personally, it took me a few minutes to make the example I sent you. At the beginning you might not know which widget to use, etc, but it get easy quite fast.
If you are new to TouchGFX, we create a few resources for you :
Regards,
2024-06-24 07:43 AM
Hello @Ricko ,
I have implemented that by putting the textArea inside a scrollable container.
In the textArea setting, I have to uncheck "Auto-size", set the width.
In the scrollable container, I have to make sure it is big enough to hold the whole textArea (the height).
I have not tried to make TouchGFX calculate that, so I put it by hand.
The height of the scrollable container could probably be set at runtime by using the textArea method "virtual int16_t getTextHeight() const" and the scrollabelContainer method setHeight.
If this answers your question, I invite you to select this comment as "best answer".
Regards,
2024-06-24 08:56 AM
Thank you @GaetanGodart
not having any experience with TouchGFX, , what I am trying to understand are two points:
1) the scrolling functionality (i.e. the code for the scrolling) is generated by the TouchGFX (or other tool) or if I need to write additional code
2) if, to do the entire scrollable text box with fixed text inside it that can be scrolled - whether like you suggested or any other way - is a few hours job or a week long job. Again this is for someone who has written a lot of C but never used UI or touch displays, let alone TouchGFX.
Thank you as alaways
Ricko
2024-06-25 01:19 AM
My pleasure!
1) the scrolling functionality (i.e. the code for the scrolling) is generated by the TouchGFX (or other tool) or if I need to write additional code
TouchGFX Generates codes based on the design you create in Designer.
The generated code can be found in the folder "generated" => "gui_generated". Those files are call xxxxxxxxBase.cpp/hpp, ex: screen1ViewBase.cpp. You should never modify these files as they get regenerated (erasing your changes) every time you click on "Generate code" in Designer.
It also creates a bunch of other files and folders. The one that matter to you are in the folder "gui", ex: screen1View.cpp (which you can modify).
In the example I made (were you able to look at the example I provided, the file with 7z extension?) the whole design inside Designer and did not code a single thing.
However, if you want to fetch the length of the textArea and set the length of the scrollable container accordingly, you would have to write some simple code in screen1View.cpp.
2) if, to do the entire scrollable text box with fixed text inside it that can be scrolled - whether like you suggested or any other way - is a few hours job or a week long job. Again this is for someone who has written a lot of C but never used UI or touch displays, let alone TouchGFX.
Well, it depends on you. Personally, it took me a few minutes to make the example I sent you. At the beginning you might not know which widget to use, etc, but it get easy quite fast.
If you are new to TouchGFX, we create a few resources for you :
Regards,
2024-06-25 04:36 AM
Thank you @GaetanGodart
2024-06-25 04:37 AM - edited 2024-06-25 04:37 AM
My pleasure!