How to add a wildcard text to a flex button?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-08-01 3:28 AM
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
Solved! Go to Solution.
- Labels:
-
TouchGFX
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-08-13 9:51 AM - last edited on ‎2024-05-02 2:10 AM by GaetanGodart
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);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-08-03 6:45 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-08-12 2:56 PM
How 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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-08-13 1:59 AM
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.
/Alexandre
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-08-13 9:51 AM - last edited on ‎2024-05-02 2:10 AM by GaetanGodart
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);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-08-13 10:48 AM
thank you!
