cancel
Showing results for 
Search instead for 
Did you mean: 

FlexButton background color how to change in code

Hab Collector
Associate III

I googled how to make this change.  I found several references to class members setBackgroundColor, setButtonColor, setBoxColor but none of them work (are members).  I checked BoxWithBorderButtonStyle.hpp and could find no reference to any of these nor any (obvious) function that would allow me to change the color.  The documentation that I can find online does not match my results.  Any feedback would be helpful.  I am using TouchGFX 4.24.2

1 ACCEPTED SOLUTION

Accepted Solutions
mƎALLEm
ST Employee

Hello,

I think you need to use:

 

    /**
     * Sets the colors.
     *
     *   colorReleased       The color released.
     *   colorPressed        The color pressed.
     *   borderColorReleased The border color released.
     *   borderColorPressed  The border color pressed.
     */
    void setBoxWithBorderColors(const colortype colorReleased, const colortype colorPressed, const colortype borderColorReleased, const colortype borderColorPressed)
    {
        up = colorReleased;
        down = colorPressed;

        borderUp = borderColorReleased;
        borderDown = borderColorPressed;

        handlePressedUpdated();
    }

 

Tip: how did I find it? 

Create a flex button and change the background colors.

mALLEm_0-1740750745820.png

Go to the ScreenXXXViewBase in "generated" folder and check what was the call corresponding to the color settings:

 

flexButton1.setBoxWithBorderColors(touchgfx::Color::getColorFromRGB(168, 209, 230), touchgfx::Color::getColorFromRGB(54, 68, 217), touchgfx::Color::getColorFromRGB(255, 255, 255), touchgfx::Color::getColorFromRGB(250, 250, 250));

 

The two first parameters correspond to the pressed/released background colors.

Hope that helps.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

View solution in original post

2 REPLIES 2
mƎALLEm
ST Employee

Hello,

I think you need to use:

 

    /**
     * Sets the colors.
     *
     *   colorReleased       The color released.
     *   colorPressed        The color pressed.
     *   borderColorReleased The border color released.
     *   borderColorPressed  The border color pressed.
     */
    void setBoxWithBorderColors(const colortype colorReleased, const colortype colorPressed, const colortype borderColorReleased, const colortype borderColorPressed)
    {
        up = colorReleased;
        down = colorPressed;

        borderUp = borderColorReleased;
        borderDown = borderColorPressed;

        handlePressedUpdated();
    }

 

Tip: how did I find it? 

Create a flex button and change the background colors.

mALLEm_0-1740750745820.png

Go to the ScreenXXXViewBase in "generated" folder and check what was the call corresponding to the color settings:

 

flexButton1.setBoxWithBorderColors(touchgfx::Color::getColorFromRGB(168, 209, 230), touchgfx::Color::getColorFromRGB(54, 68, 217), touchgfx::Color::getColorFromRGB(255, 255, 255), touchgfx::Color::getColorFromRGB(250, 250, 250));

 

The two first parameters correspond to the pressed/released background colors.

Hope that helps.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
Hab Collector
Associate III

Thank you so much - that was most helpful.