2019-08-22 07:57 AM
Hi again @Martin KJELDSEN !
I have a textarea with one wildcard with a fix width but ajustable height. If the wildcard doesn't fit I would like to have the text split in multiple lines, and/or change the text size to be smaller. Is there a simple function/setting to use for that or do I have to manually check getTextWidth()?
Thanks in advance for the help!
Solved! Go to Solution.
2019-08-22 11:42 AM
Hi @Sandy.Dahl,
You can use the WORD WRAP feature of the textarea to split your text into multiple lines.
/**
* @fn void TextArea::setWideTextAction(WideTextAction action)
*
* @brief Sets wide text action.
*
* Sets wide text action. Defines what to do if a line of text is wider than the
* text area. Default action is WIDE_TEXT_NONE which means that text lines are only
* broken if there is a newline in the text.
*
* If wrapping is enabled and the text would occupy more lines than the size of the
* TextArea, the last line will get an ellipsis to signal that some text is missing.
* The character used for ellipsis is taken from the text spreadsheet.
*
* @param action The action to perform for wide lines of text.
*
* @see WideTextAction
* @see getWideTextAction
* @see resizeHeightToCurrentText
*/
void setWideTextAction(WideTextAction action);
Basically what you'll do is define the fixed width you know your text area will have. Define your string (either statically or by wildcards) to have any length and then call the following:
/**
* @fn void TextArea::resizeHeightToCurrentText();
*
* @brief Sets the height of the TextArea.
*
* Sets the height of the TextArea to match the height of the current associated
* text for the current selected language. This is especially useful for texts with
* WordWrap enabled.
*
* Please note that if the current text rotation is either 90 or 270 degrees, the
* width of the text area will be set and not the height, as the text is rotated.
*
* @see resizeToCurrentText
* @see setWordWrap
* @see setRotation
*/
void resizeHeightToCurrentText();
This call will respect the width of your text area and attempt to split your text into multiple lines to match that (based on occurances of 0x20 - SPACE).
Give it a try!
/Martin
2019-08-22 11:42 AM
Hi @Sandy.Dahl,
You can use the WORD WRAP feature of the textarea to split your text into multiple lines.
/**
* @fn void TextArea::setWideTextAction(WideTextAction action)
*
* @brief Sets wide text action.
*
* Sets wide text action. Defines what to do if a line of text is wider than the
* text area. Default action is WIDE_TEXT_NONE which means that text lines are only
* broken if there is a newline in the text.
*
* If wrapping is enabled and the text would occupy more lines than the size of the
* TextArea, the last line will get an ellipsis to signal that some text is missing.
* The character used for ellipsis is taken from the text spreadsheet.
*
* @param action The action to perform for wide lines of text.
*
* @see WideTextAction
* @see getWideTextAction
* @see resizeHeightToCurrentText
*/
void setWideTextAction(WideTextAction action);
Basically what you'll do is define the fixed width you know your text area will have. Define your string (either statically or by wildcards) to have any length and then call the following:
/**
* @fn void TextArea::resizeHeightToCurrentText();
*
* @brief Sets the height of the TextArea.
*
* Sets the height of the TextArea to match the height of the current associated
* text for the current selected language. This is especially useful for texts with
* WordWrap enabled.
*
* Please note that if the current text rotation is either 90 or 270 degrees, the
* width of the text area will be set and not the height, as the text is rotated.
*
* @see resizeToCurrentText
* @see setWordWrap
* @see setRotation
*/
void resizeHeightToCurrentText();
This call will respect the width of your text area and attempt to split your text into multiple lines to match that (based on occurances of 0x20 - SPACE).
Give it a try!
/Martin
2019-08-22 12:44 PM
A new word wrap mode is coming where it's possible to mix languages where you break on both 0x20 and on 0x200B (Zero-Width space) to use in, for instance, Chinese.
2019-08-22 11:20 PM
Perfect, thanks, I'll try that! I assume this can't be done in the designer?
2019-08-22 11:27 PM
Unfortunately not yet :) But it's on the list of things to do!