cancel
Showing results for 
Search instead for 
Did you mean: 

how to release/pressed text inside custom container

JPabl.1
Senior

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. 

JPabl1_0-1729101170967.png

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

1 ACCEPTED SOLUTION

Accepted Solutions

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!

Mohammad MORADI
ST Software Developer | TouchGFX

View solution in original post

4 REPLIES 4

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,

Mohammad MORADI
ST Software Developer | TouchGFX
JPabl.1
Senior

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? 

 

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!

Mohammad MORADI
ST Software Developer | TouchGFX

Hello @JPabl.1 ,


Have you been able to move forward on your project?

 

Regards,

Gaetan Godart
Software engineer at ST (TouchGFX)