cancel
Showing results for 
Search instead for 
Did you mean: 

TextAreaWildCard displaying too many characters

GMeur
Senior

Hi,

Imagine I have a vector of 10 different text Areas and I want to write a different number ranging from 0 to 9 on each of them (0 on the first one, 1 on the second and so on). What's the best strategy to achieve this?

Using a wildcard definitely seems inappropriate as once the textAreas will be set up, they won't be changed for the whole duration of the program. Comparably, using a Resource with the need to introduce first all the characters in the 'database' seems overkilled. They must be another way, more appropriate and doable directly from the code.

Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions

TouchGFX operates on strings of Unicode chars. The strings need to be escaped with '\0' - So your buffers should all be of size 2.

View solution in original post

11 REPLIES 11
Martin KJELDSEN
Chief III

Hi @GMeur​,

Using a wildcard buffer for each TextArea is definitely the way to go here.

/Martin

Martin KJELDSEN
Chief III

Just to exemplify on the first option: You would have to define ten text resources and then write code that determine which of these texts should be set based on a number. This leads to more flash usage, while the second more generic/elegant solution would require less flash but more ram. I guess, sometimes when you're resource constrained you have to consider things like this.

/Martin

Is there a way to limit the size of a given buffer used to draw a test string in a textArea? I explain you why I'm asking that. If I wanna create 10 buffers holding one character each, the simplest solution would be to create an array of 10 characters. But what's that? A buffer of size 10 instead of being 10 buffers of size 1. When assigning the textBuffer it'd be awesome if I could set its size too. How can I do that easily? Thanks.

Yes, you can set the size of the buffer through the designer when you specify the wildcard.

Apparently, my message wasn't as clear as I thought… I'll examplify a bit what I meant:

Instead of seeing this:

std::array<touchgfx::Unicode::UnicodeChar,15> _test;

as a single buffer, called test, holding 15 different elements, you can see it as an array containing 15 buffers, each holding a single element, right?

But this obviously doesn't work:

aKey->setWildcardTextBuffer(&_test[i]);

As the function doesn't know the size of the buffer (it believes it's just a 'standard' buffer), and therefore, you get something like this:

0690X000008wFazQAE.png

I hope I made my point a bit clearer :)

TouchGFX operates on strings of Unicode chars. The strings need to be escaped with '\0' - So your buffers should all be of size 2.

Hi @GMeur​,

Did you get any further with this?

/Martin

Strangly, I hadn't seen your previous answer but I'd figured it out meanwhile. I should have updated my post. Thanks.

What did you come up with? Did escaping the buffers work?

/Martin