2022-04-20 08:14 AM
Is there a guide/tutorial that shows how to use it? How, for example, to invoke a specific "Resource ID" in order to fill a TextArea?
Thanks
2022-04-21 02:47 AM
Hello MDi D.1,
We don't have a tutorial, but we have this documentation that can help you.
I'll show you the basics of how use resources under TouchGFX Designer :
1- Create you project and go "Text" on the left panel.
2- Click on "Add new text" and edit the resource you want. You can modify the 'id" of your resource, the "typography", the "alignment", and finally your text. "GB" is already here by default and it's your text in English language, you can add an other language by clicking on the "+" button.
Try to edit it like this :
3- Go back to your canvas and add a new text widget
4- In right panel, click on the loupe under the "Text" section
5- Click on "Group1" and click on the new resource we just created.
6- Enjoy :)
(7- If you want to change the language of your text, go to "Config" on the left panel, and under General, change the "Selected Language", then the change will automatically take place on you canvas)
Hope this helps ;)
/Osman
2022-04-21 03:22 AM
Thanks for the explanation.
If I want to change the content of the TextArea to runtime, how do I edit it using a multilanguage resource that I added in the designer.
Obviously writing code :)
thank you
2022-04-25 02:23 AM
Hello MDi D.1,
That's very easy thing :)
Let's take an example.
You have a new TextArea, called textToChangeRuntime. When you add a textArea in the Designer, it will automatically generate some code :
In Screen1ViewBase.hpp
touchgfx::TextArea textToChangeRuntime;
And in Screen1ViewBase.cpp :
textToChangeRuntime.setTypedText(touchgfx::TypedText(T___SINGLEUSE_CT1B));
T___SINGLEUSE_CT1B is the enum referencing the resource which is automatically created when you create a TextArea. What we want is to to tell the application not to use this T___SINGLEUSE_CT1B anymore but the enum referencing the resource you've created instead. With the example of my previous post, you should have a resource called "myFirstRessource" and the enum for this would be T_MYFIRSTRESSOURCE. You can check that in your "generated\texts\include\texts\TextKeysAndLanguagfe.hpp" file.
So let's change the value of your textArea.
Go to your Screen1View.cpp, and add this line under setupScreen() function
void Screen1View::setupScreen()
{
Screen1ViewBase::setupScreen();
textToChangeRuntime.setTypedText(touchgfx::TypedText(T_MYFIRSTRESSOURCE));
textToChangeRuntime.invalidate();
}
and also the right include :
#include <texts/TextKeysAndLanguages.hpp>
And that's it ! :)
You're free to create function dedicated to this, for my example I used setupScreen() function to stay simple.
Also, if you want to switch between languages, you can add this, near the previous line :
Texts::setLanguage(ITALIAN);
in argument of this function, it's also an enum (LANGUAGES in TextKeysAndLanguages.hpp)
/Osman
2022-04-25 04:48 AM
Thank you for your support!.
I'll try your code asap.
Ciao