2021-10-27 08:46 AM
Hi, All
I have a fine working project but i don't have a designer project files.
I want to add a TextAreaWithOneWildcard modifying only source code.
I was using this article as a reference
https://support.touchgfx.com/docs/development/ui-development/ui-components/miscellaneous/text-area
I have added a code for a new control like in the article but control is not displaying.
I am missing something.
I have added also an
add(VARIABLE_NAME) in the base class of the screen. That was not described in the article above.
Maybe there are some hidden code which I can't find using notepad++ search?
Solved! Go to Solution.
2021-10-28 07:02 AM
You miss one set, in normal area need FONT and is based on existed text resource. Perfect is if your project have one TypedText with font and <value> definition in string for wildcard. Then your line need change to
textAreaXXX.setTypedText(touchgfx::TypedText(T_SINGLEUSEID1));
when you dont have existed resource, you need add to more files for example into TypedTextDatabase.cpp ...
too without project you cant add new font ...
2021-10-27 09:10 AM
Why you dont show code here?
2021-10-28 12:54 AM
Hi,
As MM said sharing your code would help us see if you have forgotten something or not. What do you mean exactly by "control" ?
Just to verify something, you wrote that you added "an add(VARIABLE_NAME) in the base class of the screen. Be careful, you should never put user code in files in the generated folder (so typically <name of screen>ViewBase.cpp/hpp files) as they will get overwritten at every TouchGFX Designer code generation, so this is a bad habit to have.
/Romain
2021-10-28 06:23 AM
Hi All, and thanks for reply.
>>Be careful, you should never put user code in files in the generated folder
Yeah. I am in a bit non standard situation. I don't have a designer project and trying to add new control manually. Not a bad way to learn how TouchGFX internally organized.
So here is my source code:
I have added a variable definition to the class which is derived from system class in the following way
class FDRScrViewBase : public touchgfx::View<FDRScrPresenter>
The variable definition:
touchgfx::TextAreaWithOneWildcard TxPowerArea;
Than in constructor of FDRScrViewBase i have added
add(TxPowerArea);
Than there is a class FDRScrView : public FDRScrViewBase
In it's constructor i have added:
TxPowerArea.setPosition(0, 100, 137, 15);
TxPowerArea.setColor(touchgfx::Color::getColorFrom24BitRGB(196, 196, 196));
TxPowerArea.setLinespacing(0);
TxPowerArea.setTypedText(touchgfx::TypedText());
TxPowerArea.setWildcard(TxPowerArea_text);
TxPowerArea.setVisible(true);
Then there is a method
void FDRScrView::handleTickEvent()
I have added the following lines
Unicode::snprintf(TxPowerArea_text, 4, "HELO");
TxPowerArea.invalidate();
There is a definition of TxPowerArea_text in the FDRScrView class
Unicode::UnicodeChar TxPowerArea_text[15];
I have checked with debugger that all lines of code are executed.
I don't see any text on the screen.
2021-10-28 07:02 AM
You miss one set, in normal area need FONT and is based on existed text resource. Perfect is if your project have one TypedText with font and <value> definition in string for wildcard. Then your line need change to
textAreaXXX.setTypedText(touchgfx::TypedText(T_SINGLEUSEID1));
when you dont have existed resource, you need add to more files for example into TypedTextDatabase.cpp ...
too without project you cant add new font ...
2021-10-28 07:21 AM
Thanks a lot. MM..1.
It worked!!!
I was confused by documentation that stated that font id is an optional parameter.
I thought that it will work without any font specification.
Many thanks!!