cancel
Showing results for 
Search instead for 
Did you mean: 

Changing Flex Button Text by Pointer

Natali
Associate III

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();
    
}

 

1 ACCEPTED SOLUTION

Accepted Solutions
JTP1
Lead

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:

https://community.st.com/t5/stm32-mcus-touchgfx-and-gui/how-do-i-trigger-a-new-virtual-function-when-a-touch-button/td-p/52581

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

View solution in original post

1 REPLY 1
JTP1
Lead

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:

https://community.st.com/t5/stm32-mcus-touchgfx-and-gui/how-do-i-trigger-a-new-virtual-function-when-a-touch-button/td-p/52581

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