cancel
Showing results for 
Search instead for 
Did you mean: 

Set attribute of flexbutton with code on CallbackHandler

Emilmart
Senior

Hello,

I have multiple flexbutton and I'd like to change the border size of the button which is pressed only.

In GFX interraction panel I could of course excecute C++ code like flexButtonName.setBorderSize(5); but I'd like to have it in a generic function, with a flexbutton pointer, like this :

void Screen1ViewBase::flexButtonCallbackHandler(const touchgfx::AbstractButtonContainer& src)
{
    if (&src == &flexButtonName)
    {
        //InteractionName
        Screen1View::changeBorderSize(&src); // 
    }
}
 
// Screen1View.cpp
changeBorderSize(const touchgfx::TextButtonStyle<touchgfx::BoxClickButton>& src)
{
        src.setBorderSize(5); // I got build error: "incomplete type 'Screen1View' used in nested name specifier"
}

But I got an error "incomplete type 'Screen1View' used in nested name specifier", it seems that I failed my cast somewhere.

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Emilmart
Senior

I solved my problem. 3 steps in touchGFX:

In Screen1: create an action changeBorderSize with a custom type touchgfx::TextButtonStyle<touchgfx::BoxClickButton>&

In interraction: create an interraction when changeBorderSize is called, with action execute C++ code : value.setBorderSize(5);

In interraction: create an button click interraction for the flexButtonName and call the changeBorderSize function with flexButtonName as argument

thanks

View solution in original post

3 REPLIES 3
MM..1
Chief II

Maybe little swap

void Screen1ViewBase::flexButtonCallbackHandler(const touchgfx::AbstractButtonContainer& src)
{
    if (&src == &flexButtonName)
    {
        //InteractionName
        changeBorderSize(&src); // in base hpp as virtual 
    }
}
 
// Screen1View.cpp
Screen1View::changeBorderSize(const touchgfx::TextButtonStyle<touchgfx::BoxClickButton>& src)
{
        src.setBorderSize(5); // I got build error: "incomplete type 'Screen1View' used in nested name specifier"
}

Hi @MM..1​ , thanks for your answer.

Screen1ViewBase.hpp is generated only so I had to call a new virtual function changeBorderSize on InterractionName in touchGFX. But I can't pass any argument (&src) in it. Should I make a custom container with a custom trigger instead ?

Even if I implement changeBorderSize in Screen1View I got the following error :

error: passing 'const touchgfx::TextButtonStyle<touchgfx::BoxWithBorderButtonStyle<touchgfx::ClickButtonTrigger> >' as 'this' argument discards qualifiers [-fpermissive]

  48 | src.setBorderSize(5);

thanks

Emilmart
Senior

I solved my problem. 3 steps in touchGFX:

In Screen1: create an action changeBorderSize with a custom type touchgfx::TextButtonStyle<touchgfx::BoxClickButton>&

In interraction: create an interraction when changeBorderSize is called, with action execute C++ code : value.setBorderSize(5);

In interraction: create an button click interraction for the flexButtonName and call the changeBorderSize function with flexButtonName as argument

thanks