Skip to main content
Kasun Dinesh
Associate III
August 1, 2020
Solved

How to add a wildcard text to a flex button?

  • August 1, 2020
  • 2 replies
  • 1940 views

Hi,

I have created flex buttons from the code (not from touchgfx GUI). I want to know how can i add wildcard text to the buttons. End result is button text should be able to change according to the string i feed it when i create the class (initialize).

Thanks

This topic has been closed for replies.
Best answer by Kasun Dinesh

Hi all, Thanks for trying to help me out. Actually i was able to solve the problem.

 

I created the flex buttons like this.

touchgfx::IconButtonStyle< touchgfx::WildcardTextButtonStyle< touchgfx::ImageButtonStyle< touchgfx::ClickButtonTrigger > > > button[MAX_BTN_COUNT];
Unicode::UnicodeChar txtBuffer[MAX_TXT_BUFF_SIZE];

 

Then i created a text template from touchgfx UI and added to the text.

button[button_id].setWildcardTextPosition(20, 20, button_width - 40, button_height - 40);
button[button_id].setWildcardText(TypedText(T_BUTTON2X2TEXTRESOURCE));
button[button_id].setWildcardTextBuffer(txtBuffer);

 

Aditionnaly i had to comment these lines on WildcardTextButtonStyle.hpp

 

 void setWildcardText(TypedText t)
 {
 wildcardText.setTypedText(t);
 // wildcardText.setWidth(T::getWidth());
 // wildcardText.setHeight(T::getHeight());
 wildcardText.setWideTextAction(WIDE_TEXT_WORDWRAP);
 }

 

2 replies

Alexandre RENOUX
Visitor II
August 3, 2020

Hello,

I don't understand why you don't want to use the Designer for something that can be done in the Designer. The Designer was made to help people for things like this.

If you want to still do it manually, create a dummy project with a flex button with wildcard and then copy paste the code (with slight modification).

You declare your Flexbutton in your ScreenView.hpp but you will still have to create your Text Resources with wildcard in the Designer to generate the Text IDs.

/Alexandre

MElwa.1
Visitor II
August 12, 2020

0693W000003PDPQQA4.pngHow does one create a Flex Button w/ wildcard in the designer then? I don't see that option. I have a container called MenuItem with a single component - a flex button. I need to be able to change this text on the fly using Unicode string commands.

Alexandre RENOUX
Visitor II
August 13, 2020

Hello,

You don't have the wildcard possibility because your resource MenuItemText has no wildcard.

You have to add a <> in the text field of your resource to indicate there is a wildcard.

0693W000003PF3WQAW.png

/Alexandre

Kasun Dinesh
Kasun DineshAuthorBest answer
Associate III
August 13, 2020

Hi all, Thanks for trying to help me out. Actually i was able to solve the problem.

 

I created the flex buttons like this.

touchgfx::IconButtonStyle< touchgfx::WildcardTextButtonStyle< touchgfx::ImageButtonStyle< touchgfx::ClickButtonTrigger > > > button[MAX_BTN_COUNT];
Unicode::UnicodeChar txtBuffer[MAX_TXT_BUFF_SIZE];

 

Then i created a text template from touchgfx UI and added to the text.

button[button_id].setWildcardTextPosition(20, 20, button_width - 40, button_height - 40);
button[button_id].setWildcardText(TypedText(T_BUTTON2X2TEXTRESOURCE));
button[button_id].setWildcardTextBuffer(txtBuffer);

 

Aditionnaly i had to comment these lines on WildcardTextButtonStyle.hpp

 

 void setWildcardText(TypedText t)
 {
 wildcardText.setTypedText(t);
 // wildcardText.setWidth(T::getWidth());
 // wildcardText.setHeight(T::getHeight());
 wildcardText.setWideTextAction(WIDE_TEXT_WORDWRAP);
 }