2025-01-06 02:36 PM - last edited on 2025-01-07 09:06 AM by Andrew Neil
hi
I wrote a function similar to the one below for changing the text of a Text Area, and it works perfectly. However, I encountered an issue with Flex Button. This part of the code gives an error:
touchgfx::WildcardTextButtonStyle &FlexBtn
void FlexButtonSetText( touchgfx::WildcardTextButtonStyle &FlexBtn, touchgfx::Unicode::UnicodeChar *UnicodeText , char * text )
{
Unicode::fromUTF8( (uint8_t *)text , UnicodeText , strlen(text)+1 );
FlexBtn.setWildcardTextBuffer(UnicodeText);
FlexBtn.invalidate();
}
Solved! Go to Solution.
2025-01-07 08:58 AM - edited 2025-01-07 08:59 AM
Hello Natali
I think it does not work because your flexbutton is inheritated from more than one class. So 'touchgfx::WildcardTextButtonStyle' is most likely not proper type definition for your flexButton.
Check your base.hpp file to see how your flexButton defined. If you check 'text' and 'box with border' properties, it will be like:
touchgfx::WildcardTextButtonStyle< touchgfx::BoxWithBorderButtonStyle< touchgfx::ClickButtonTrigger > > flexButton1;
so this works like:
Screen1View::Screen1View()
{
static touchgfx::Unicode::UnicodeChar testUnicodeBuffer[10]; // Must static or global since this buffer is set as buffer for flexButton1
char charBuf[10]={"TESTTEXT"};
FlexButtonSetText(flexButton1,testUnicodeBuffer,charBuf);
}
void Screen1View::FlexButtonSetText(touchgfx::WildcardTextButtonStyle< touchgfx::BoxWithBorderButtonStyle< touchgfx::ClickButtonTrigger > > &FlexBtn, touchgfx::Unicode::UnicodeChar *UnicodeText , char * text )
{
Unicode::fromUTF8( (uint8_t *)text , UnicodeText , strlen(text)+1 );
FlexBtn.setWildcardTextBuffer(UnicodeText);
FlexBtn.invalidate();
}
Please check this thread also, it might help you:
Anycase I don't know how useful this function is, though, because it overwrites the original wildcard buffer of flexButton. But hope this helps you
BR JTP
2025-01-07 08:58 AM - edited 2025-01-07 08:59 AM
Hello Natali
I think it does not work because your flexbutton is inheritated from more than one class. So 'touchgfx::WildcardTextButtonStyle' is most likely not proper type definition for your flexButton.
Check your base.hpp file to see how your flexButton defined. If you check 'text' and 'box with border' properties, it will be like:
touchgfx::WildcardTextButtonStyle< touchgfx::BoxWithBorderButtonStyle< touchgfx::ClickButtonTrigger > > flexButton1;
so this works like:
Screen1View::Screen1View()
{
static touchgfx::Unicode::UnicodeChar testUnicodeBuffer[10]; // Must static or global since this buffer is set as buffer for flexButton1
char charBuf[10]={"TESTTEXT"};
FlexButtonSetText(flexButton1,testUnicodeBuffer,charBuf);
}
void Screen1View::FlexButtonSetText(touchgfx::WildcardTextButtonStyle< touchgfx::BoxWithBorderButtonStyle< touchgfx::ClickButtonTrigger > > &FlexBtn, touchgfx::Unicode::UnicodeChar *UnicodeText , char * text )
{
Unicode::fromUTF8( (uint8_t *)text , UnicodeText , strlen(text)+1 );
FlexBtn.setWildcardTextBuffer(UnicodeText);
FlexBtn.invalidate();
}
Please check this thread also, it might help you:
Anycase I don't know how useful this function is, though, because it overwrites the original wildcard buffer of flexButton. But hope this helps you
BR JTP