656 views
in GUI Development by
Hello,

I noticed, that the %-sign is an escape character when used within the String-property of a text view.
Sadly I could not find any explanation about the functionality of this character in the documentation.

Could you please explain what it is used for?

Thank you very much!

1 Answer

+1 vote
by

The description of the special characters used within the 'String' property of 'Views::Text' items is placed directly in the 'Description' field of the property: Just select the property 'String' within the Inspector, then you can see the corresponding description:

The property 'String' stores the text to print in this view. The corresponding font is determined by the property 'Font'. The text can consist of several rows separated by the new-line sign '\n'. Optionally an automatic text wrap can be performed if the property 'WrapText' is 'true'. The automatic text wrap takes place primarily between words. 

More sophisticated text wrap can be controlled by following special signs used within the text:

  • The tilde sign '~' and the soft-hyphen sign '\x00AD' identify a potential text wrap position. They are usually not displayed until the text wrap took place at their position. Then the text row is terminated with a hyphen '-' sign.
  • The circumflex accent '^' sign identifies a potential text wrap position without ever being visible.

In order to be able to output the special characters '^', '~' and '\x00AD' as regular signs, the character '%' can be applied in front of the affected sign to convert it to a regular sign. 

To show the '%' sign itself, use '%%' sequence.

by
Hi,

I have similar issue with displaying % character. I am fetching unit string for various kinds of sensor objects and the string could be anything.

Also it is possible for me to have some run time strings with '^', '~'  characters. Is there string function available which could check for these characters and add % before each time one of the above character is present and return the expected string.

Otherwise I think I would need to write a function for string parsing and then add the % before the above characters.

Any suggestions would be much appreciated!

Thanks,

Vikas
by
Hi Vikas,

you can either parse the string and create a new string containing the '%' character - or you can adapt your string providing functions so that they already return a string with the correct '%' character sequence.

Maybe the best solution is, that your data provided just returns the value as some int32 and you create the string when it will be displayed.

Best regards,

Manfred.
by
Hi

I have a issue with the length of the string which has '^', '~','%' character.

For correct display the string"^~%", I should use "%^%~%%", but the length of the "%^%~%%" is 6, I wish to know the true length is 3("^~%").

I want to ask Embeded Wizard  whether or not have the function to calculate the true length of the string, not contain Escape character length.

Thank you very much!
by
Hi Sancia,

in this case you have to parse the string and count all characters that you want to consider - e.g. you can skip all leading '%' characters and count all other characters.

Best regards,

Manfred.

Ask Embedded Wizard

Welcome to the question and answer site for Embedded Wizard users and UI developers.

Ask your question and receive answers from the Embedded Wizard support team or from other members of the community!

Embedded Wizard Website | Privacy Policy | Imprint

...