cancel
Showing results for 
Search instead for 
Did you mean: 

How to add a wildcard text to a flex button?

Kasun Dinesh
Associate III

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

1 ACCEPTED SOLUTION

Accepted Solutions
Kasun Dinesh
Associate III

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);

  }

View solution in original post

5 REPLIES 5
Alexandre RENOUX
Principal

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

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.

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
Associate III

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);

  }

thank you!