Text (텍스트) Widget Control
The Widget Control (Property · Method · Event) you use to control the Text widget from a script. To learn about the widget itself and how to use it, see the Text doc.
Example file: 07_Work_with_Widgets/text_objet.lfp
In the examples below, textID is the name (ID) assigned to the Text widget on the canvas. In scripts, access members as widgetID.member.
Widget Control summary
| Widget Control | Kind | Signature | Description |
|---|---|---|---|
text | Property | string (Read/write) | The text content to display |
orgText | Property | string (Read-only) | The original text before data binding |
color | Property | string (Read/write) | The text color |
setText | Method | setText(s: string): void | Sets the text content |
setFontSize | Method | setFontSize(size: number): void | Sets the font size |
setTextColor | Method | setTextColor(color: string): void | Sets the text color |
setStyledText | Method | setStyledText(styledData): void | Sets text with several inline styles applied |
clearStyledText | Method | clearStyledText(): void | Clears the styled text |
setTextStyle | Method | setTextStyle(style): void | Sets the text style in one call |
Property
text
The text content to display. Both readable and writable.
- Type:
string - Access: Read / write
Example
// Change the text
textID.text = "안녕하세요";
// Read the current text
const current = textID.text;
orgText
Returns the original — pre-processing — value of data-bound text. Without a binding, it returns the same value as text.
- Type:
string - Access: Read-only
Example
const original = textID.orgText;
color
The text color. Both readable and writable.
- Type:
string(a color token string, for exampleLabel/tertiary) - Access: Read / write
Example
textID.color = "Label/tertiary";
const c = textID.color;
Method
setText
Sets the text content.
- Parameters
s(string): The text to display
- Returns: None (
void)
Example
textID.setText("안녕하세요");
setFontSize
Sets the font size.
- Parameters
size(number): Font size in logical pixels
- Returns: None (
void)
Example
textID.setFontSize(16.0);
setTextColor
Sets the text color.
- Parameters
color(string): A color token string (for exampleLabel/tertiary)
- Returns: None (
void)
Example
textID.setTextColor("Label/tertiary");
setStyledText
Sets text that carries several inline styles — style spans.
- Parameters
styledData: An array of span objects,[{ text, color? }]. Each span hastextand an optional color token,color.
- Returns: None (
void) - Behavior: Once you set styled text, it renders with priority over the
textproperty.
Example
textID.setStyledText([
{ text: "진행중 " },
{ text: `${count}`, color: "Label/highlight" },
{ text: "건" }
]);
clearStyledText
Clears the styled text applied with setStyledText.
- Parameters: None
- Returns: None (
void)
Example
textID.clearStyledText();
setTextStyle
Sets the text style in one call.
- Parameters
style(string): A text style token (for examplebody1-medium)
- Returns: None (
void)
Example
textID.setTextStyle("body1-medium");
Event
Not applicable — the Text widget has no dedicated Event.
Common Widget Control (all widgets)
Every widget can also use common Widget Control (Method) such as setProperty(name, value) / getProperty(name) / setStyleProperty(styleName, styleProperty, value). For the detailed rules, see the common Widget Control reference.