cancel
Showing results for 
Search instead for 
Did you mean: 

TouchGFX change button text

Schamann
Associate II

Hello, I try to do my own keyboard.

My idea: when click on shift button (red a, btnShift) i want replace big letters with small. All buttons are FlexButton

Can I use the Action Execute C++ code ?

like this:

btnA.setText(TypedText('a'));

but not woking now :( 

Schamann_0-1714601554516.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
Nathan_Xi
Associate III

Hello, Schamann.

To change the button text, you can use text resources to switch original texts to new texts.

This can be done by setting up wildcards and text resources.

If you want to change your text, you should open up your project and manually change the wildcard content.

In this way you'll be able to fix that bug.

If you find my answer useful, it'll be nice of you to click on "accept as solution".

Good luck.

Nathan Xi

View solution in original post

4 REPLIES 4
Nathan_Xi
Associate III

Hello, Schamann.

To change the button text, you can use text resources to switch original texts to new texts.

This can be done by setting up wildcards and text resources.

If you want to change your text, you should open up your project and manually change the wildcard content.

In this way you'll be able to fix that bug.

If you find my answer useful, it'll be nice of you to click on "accept as solution".

Good luck.

Nathan Xi

Hello @Schamann ,

As our friend @Nathan_Xi mentioned, the easiest way would be to define all the texts that you want to use in your GUI inside the TouchGFX Designer -> Texts. And also set the characters you want to use inside the wildcard range.
Afterward, in your code you need to include texts/TextKeysAndLanguages.hpp, then you can use the function you mentioned to change the label of the flex button. Keep in mind that you need to provide the ID that you assigned to your text inside TypedText().
It would look something like this:

Setting Wildcard rangesSetting Wildcard ranges

Text definition inside TouchGFXText definition inside TouchGFX

 

//Inside your ScreenView.cpp
#include <texts/TextKeysAndLanguages.hpp>

//An interaction set inside the designer for a button click
void ScreenView::changeLetterToSmall()
{
    btnA.setText(TypedText(T_SMALL_A));
    btnA.invalidateContent();
}

 

 

I hope this helps you, don't hesitate to ask more questions

Mohammad MORADI
ST Software Developer | TouchGFX

Thank you for your replenish to this topic! @Mohammad MORADI ESFAHANIASL

It's essential to make replies comprehensively, and I'll pay attention to that in future replies;).

It's pretty nice of you!

Thank you @Nathan_Xi, for participating in the community to make it better every single day. It's lovely to see individuals like you assisting others in achieving their goals.

Wish you the best! 

Mohammad MORADI
ST Software Developer | TouchGFX