2024-07-26 12:03 PM
I am working in touch GFX 4.21.1
I do not know if it is the product of the version I am working in but I need to use wildcard characters. By all the posts and examples I have seen I am told they are generated in the #name#ViewBase.hpp file. Sadly I have not been able to replicate this behavior. I want to use Unicode::snprintf. All example I see use the generated variables. I think I could just make the variables myself in the view.h file. If I don't have to, so they can update depending on how the view updates, that would be preferred. If there is any advice on this subject please let me know.
I will also preference that the touchgfx::TextAreaWithOneWildcard does generate appropriately. Only the buffer and size are missing to my best knowledge.
Thank you for your time.
Solved! Go to Solution.
2024-07-26 11:04 PM - edited 2024-07-26 11:06 PM
Hi Tmehok
Have you configurate wildcard buffer properly to your text area ?
1. First add one wildcard buffer
2. Then you can remove 'New Text' and leave just <value> to translation (this value means the wildcard content). Otherwise you will allways get some constant text before your wildcard content. Sometimes this can be useful, but mostly it isn't.
3. Then open wildcard 1- submenu
4. Check 'Use wildcard buffer' option.
Then you can also adjust size of your buffer and put some initial value to the buffer, if needed.
After regerate the code, buffer and size definition is generated to view.hpp, at least I've never had any problems creating it.
Please note also that you must list all possible characters to the Texts - Typographies page:
For example this range 0x20-0x7F covers numbers and letters and other basic characters. It you try to print character out of defined range, fallback characters (as default it is '?') is printed instead.
Here you find more information about defining the wildcard characters:
https://support.touchgfx.com/docs/development/ui-development/designer-user-guide/texts-view
Hope this helps you.
BR JTP
2024-07-26 11:04 PM - edited 2024-07-26 11:06 PM
Hi Tmehok
Have you configurate wildcard buffer properly to your text area ?
1. First add one wildcard buffer
2. Then you can remove 'New Text' and leave just <value> to translation (this value means the wildcard content). Otherwise you will allways get some constant text before your wildcard content. Sometimes this can be useful, but mostly it isn't.
3. Then open wildcard 1- submenu
4. Check 'Use wildcard buffer' option.
Then you can also adjust size of your buffer and put some initial value to the buffer, if needed.
After regerate the code, buffer and size definition is generated to view.hpp, at least I've never had any problems creating it.
Please note also that you must list all possible characters to the Texts - Typographies page:
For example this range 0x20-0x7F covers numbers and letters and other basic characters. It you try to print character out of defined range, fallback characters (as default it is '?') is printed instead.
Here you find more information about defining the wildcard characters:
https://support.touchgfx.com/docs/development/ui-development/designer-user-guide/texts-view
Hope this helps you.
BR JTP
2024-07-27 12:46 AM
Have you place the text area directly to screen or is it inside in some container ?
If its in some container, you must write simple function to container to be able access text buffer from view- class.
Br JTP
2024-07-28 08:56 AM
I do not know if it is appropriate to say on this forum but I could kiss you. I put extra hours into work to get this working and I FORGOT TO CHECK USE THE BUFFER. It did not generate everything until I clicked that. You made this engineer very happy today. Thank you very much.
2024-07-28 11:00 AM - edited 2024-07-28 11:00 AM
Haha, let's not do it in public, at least :D But I'm glad you got your problem solved !
Here is link to documentation, it might be useful for somebody with other issues with text areas:
Br JTP
2024-07-29 01:37 AM
HI, could you come up with an example of how to access a textfield in a container?
Br. Stig
2024-07-29 11:34 AM
Ok, here is simple example.
There is container name CustomContainer which has text area called 'textArea1' with wildcard buffer activated (size 20). In Screen1, there are few of those customContainers.
Then in setupScreen function of view-class CustomContainer1 & CustomContainer2 text is changed. CustomContainer1 text is set from integer variable value and CustomContainer2 is set from constant text resource (called 'Text1). Resource is defined in TGFX Designer.
Screen1View.cpp:
#include <gui/screen1_screen/Screen1View.hpp>
// This is needed if text constanst are used
#include <texts/TextKeysAndLanguages.hpp>
Screen1View::Screen1View()
{
}
void Screen1View::setupScreen()
{
Unicode::UnicodeChar tempText[20];
int16_t newValue=1234;
Screen1ViewBase::setupScreen();
// places value from variable to customContainer1
Unicode::snprintf(tempText, 20, "%d", newValue);
customContainer1.setText(tempText);
// places a constant text string TEXT1 to customContainer2
// NOTE! Add text name 'Text1' to texts -> Texts at TGFX Designer
Unicode::snprintf(tempText, 20, "%s", TypedText(T_TEXT1).getText());
customContainer2.setText(tempText);
}
void Screen1View::tearDownScreen()
{
Screen1ViewBase::tearDownScreen();
}
CustomContainer.cpp
// add this function
void CustomContainer::setText(Unicode::UnicodeChar * text)
{
Unicode::snprintf(textArea1Buffer, TEXTAREA1_SIZE, "%s", text);
textArea1.resizeToCurrentText();
textArea1.invalidate();
}
CustomContainer.hpp
// Add this to public- funtion:
void setText(Unicode::UnicodeChar * text);
Hope this helps.
Br JTP
2024-07-29 01:49 PM
Thanks a lot, I got it working