Skip to main content
JSmit.11
Associate II
October 27, 2021
Solved

Add TextAreaWithOneWildcard WITHOUT designer project.

  • October 27, 2021
  • 5 replies
  • 1455 views

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?

This topic has been closed for replies.
Best answer by MM..1

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 ...

5 replies

MM..1
Super User
October 27, 2021

Why you dont show code here?

Romain DIELEMAN
ST Employee
October 28, 2021

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

JSmit.11
JSmit.11Author
Associate II
October 28, 2021

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.

MM..1
MM..1Best answer
Super User
October 28, 2021

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 ...

JSmit.11
JSmit.11Author
Associate II
October 28, 2021

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!!