Skip to main content
justin11
Senior
March 23, 2023
Solved

setTypedText & Unicode::snprintf on the same textArea

  • March 23, 2023
  • 2 replies
  • 2114 views

i have a textArea called endPoint_Value which i would like to write both text from the TypeText ids using the setTypedText, but i also on different occations need to use the Unicode::snprintf & Unicode::snprintFloat

The textArea has a wildcard and buffer applied to in in TouchGFX Designer

Unicode::snprintf ( endPoint_ValueBuffer, ENDPOINT_VALUE_SIZE, "%d", *( menu_ActiveEndPoint->Value_u8 ) );
 
 
Unicode::snprintfFloat ( endPoint_ValueBuffer, ENDPOINT_VALUE_SIZE, "%02.1f", *( menu_ActiveEndPoint->Value_f ) );
 
 
endPoint_Value.setTypedText ( TypedText ( T_MNUDEVICE_CONFIG ) );

each of these line work perfectly and the text changes as expected.

However, as soon as i use the "setTypedText" the "snprintf" no longer seems to work on the textArea.

I do use the endPoint_Value.invalidate ();

It seems the textArea is no longer attached to the wildcard or something like that. i've tried the endPoint_Value.setWildcard (endPoint_ValueBuffer);, but that hasn't helped.

Any suggestions whats happening ?

Cheers

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

If you sometimes use setTypedText- function, you must then set back the original text resource to get wildcard buffer text visible again. Something like this:

endPoint_Value.setTypedText ( TypedText ( T___SINGLEUSE_FZH0) ); // check the base class cpp- file to find out your wildcardbuffer resource name, T___SINGLEUSE_FZH0 is just example
 
// after that this works:
Unicode::snprintf ( endPoint_ValueBuffer, ENDPOINT_VALUE_SIZE, "%d", *( menu_ActiveEndPoint->Value_u8 ) );

Or you can simply print constant text like this to avoid hole problem (maybe easier):

Unicode::snprintf ( endPoint_ValueBuffer, ENDPOINT_VALUE_SIZE, "%s",TypedText(T_MNUDEVICE_CONFIG ).getText());

2 replies

JTP1Best answer
Graduate II
March 23, 2023

If you sometimes use setTypedText- function, you must then set back the original text resource to get wildcard buffer text visible again. Something like this:

endPoint_Value.setTypedText ( TypedText ( T___SINGLEUSE_FZH0) ); // check the base class cpp- file to find out your wildcardbuffer resource name, T___SINGLEUSE_FZH0 is just example
 
// after that this works:
Unicode::snprintf ( endPoint_ValueBuffer, ENDPOINT_VALUE_SIZE, "%d", *( menu_ActiveEndPoint->Value_u8 ) );

Or you can simply print constant text like this to avoid hole problem (maybe easier):

Unicode::snprintf ( endPoint_ValueBuffer, ENDPOINT_VALUE_SIZE, "%s",TypedText(T_MNUDEVICE_CONFIG ).getText());

justin11
justin11Author
Senior
March 23, 2023

fantastic !! thant makes perfect sense, cheers