how to release/pressed text inside custom container
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-10-16 10:55 AM
Hi there Touchgfx team!
I've this screen requirement, a list of settings. I'm doing it with a custom container that I already created. My custom container has a flex button with text(on the left) + the text on the right.
What I need is that once the user presses the button, the text color changes to white. Once its released, changes back to black. The flex button works perfect, but I'm having trouble setting it up for the right text.
I could add the white and black images, or creating a function to check if the button is pressed every n ticks, but that seems cumbersome. Is there any other way?
Thanks a lot in advance
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
‎2024-10-21 2:18 AM
It is the same concept. You just need to replace the code related to the screen with your custom container that is holding your flex button. For instance, the callback and function handler would be like:
class CustomContainer1 : public CustomContainer1Base
{
public:
CustomContainer1();
virtual ~CustomContainer1() {}
virtual void initialize();
void flexButtonClickHandler(const touchgfx::BoxWithBorderButtonStyle< touchgfx::ClickButtonTrigger >&, const ClickEvent& e);
protected:
Callback<CustomContainer1, const touchgfx::BoxWithBorderButtonStyle< touchgfx::ClickButtonTrigger >&, const ClickEvent&> flexButtonClickedCallback;
};
I hope this helps you!
ST Software Developer | TouchGFX
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-10-17 2:56 AM
Hello @JPabl.1,
You can use the ClickListener() to get the state of the flex button (either Pressed or Released) and change the color your text based on that.
Please follow the accepted solution in this forum thread.
Best regards,
ST Software Developer | TouchGFX
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-10-18 7:49 AM
Hi @Mohammad MORADI ESFAHANIASL thanks for the quick reply.
I have the flex button inside a custom container. The example you send is inside a view, so I''m having a hard time wrapping my head around the callback function from the custom container.
How can I do that?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-10-21 2:18 AM
It is the same concept. You just need to replace the code related to the screen with your custom container that is holding your flex button. For instance, the callback and function handler would be like:
class CustomContainer1 : public CustomContainer1Base
{
public:
CustomContainer1();
virtual ~CustomContainer1() {}
virtual void initialize();
void flexButtonClickHandler(const touchgfx::BoxWithBorderButtonStyle< touchgfx::ClickButtonTrigger >&, const ClickEvent& e);
protected:
Callback<CustomContainer1, const touchgfx::BoxWithBorderButtonStyle< touchgfx::ClickButtonTrigger >&, const ClickEvent&> flexButtonClickedCallback;
};
I hope this helps you!
ST Software Developer | TouchGFX
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-11-11 5:08 AM
Hello @JPabl.1 ,
Have you been able to move forward on your project?
Regards,
Software engineer at ST (TouchGFX)
