Skip to main content

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.

info

Example file: 07_Work_with_Widgets/text_objet.lfp

info

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 ControlKindSignatureDescription
textPropertystring (Read/write)The text content to display
orgTextPropertystring (Read-only)The original text before data binding
colorPropertystring (Read/write)The text color
setTextMethodsetText(s: string): voidSets the text content
setFontSizeMethodsetFontSize(size: number): voidSets the font size
setTextColorMethodsetTextColor(color: string): voidSets the text color
setStyledTextMethodsetStyledText(styledData): voidSets text with several inline styles applied
clearStyledTextMethodclearStyledText(): voidClears the styled text
setTextStyleMethodsetTextStyle(style): voidSets 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 example Label/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 example Label/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 has text and an optional color token, color.
  • Returns: None (void)
  • Behavior: Once you set styled text, it renders with priority over the text property.

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 example body1-medium)
  • Returns: None (void)

Example

textID.setTextStyle("body1-medium");

Event​

info

Not applicable — the Text widget has no dedicated Event.

Common Widget Control (all widgets)​

note

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.