Skip to main content
Emilmart
Associate III
April 6, 2021
Solved

Set attribute of flexbutton with code on CallbackHandler

  • April 6, 2021
  • 2 replies
  • 1199 views

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

This topic has been closed for replies.
Best answer by Emilmart

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

2 replies

MM..1
Chief III
April 6, 2021

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"
}

Emilmart
EmilmartAuthor
Associate III
April 7, 2021

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
EmilmartAuthorBest answer
Associate III
April 7, 2021

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