メインコンテンツまでスキップ

Text (텍스트) Widget Control

Textウィジェットをスクリプトから制御する際に使用するWidget Control(Property · Method · Event)の一覧です。ウィジェットの紹介と使い方はTextドキュメントを参照してください。

備考

サンプルファイル: 07_Work_with_Widgets/text_objet.lfp

備考

以下の例のtextIDは、キャンバスでTextウィジェットに指定した名前(ID)です。スクリプトではwidgetID.memberの形式でアクセスします。

Widget Control一覧

Widget Control種類シグネチャ説明
textPropertystring(読み取り/書き込み)表示するテキストの内容
orgTextPropertystring(読み取り専用)データバインディング前の元のテキスト
colorPropertystring(読み取り/書き込み)文字色
setTextMethodsetText(s: string): voidテキストの内容を設定
setFontSizeMethodsetFontSize(size: number): void文字サイズを設定
setTextColorMethodsetTextColor(color: string): void文字色を設定
setStyledTextMethodsetStyledText(styledData): void複数のインラインスタイルが適用されたテキストを設定
clearStyledTextMethodclearStyledText(): voidスタイルテキストを解除
setTextStyleMethodsetTextStyle(style): voidテキストスタイルを一括設定

Property

text

表示するテキストの内容です。読み取りと書き込みの両方が可能です。

  • : string
  • アクセス: 読み取り / 書き込み

Example

// テキストを変更
textID.text = "안녕하세요";

// 現在のテキストを読み取り
const current = textID.text;

orgText

データバインディングされたテキストの元の(加工前)値を返します。バインディングがない場合はtextと同じ値を返します。

  • : string
  • アクセス: 読み取り専用

Example

const original = textID.orgText;

color

文字色です。読み取りと書き込みの両方が可能です。

  • : string(カラートークン文字列、例: Label/tertiary
  • アクセス: 読み取り / 書き込み

Example

textID.color = "Label/tertiary";
const c = textID.color;

Method

setText

テキストの内容を設定します。

  • Parameters
    • s (string): 表示するテキスト
  • Returns: なし(void

Example

textID.setText("안녕하세요");

setFontSize

文字サイズを設定します。

  • Parameters
    • size (number): 文字サイズ(論理ピクセル)
  • Returns: なし(void

Example

textID.setFontSize(16.0);

setTextColor

文字色を設定します。

  • Parameters
    • color (string): カラートークン文字列(例: Label/tertiary
  • Returns: なし(void

Example

textID.setTextColor("Label/tertiary");

setStyledText

複数のインラインスタイルが適用されたテキスト(スタイルスパン)を設定します。

  • Parameters
    • styledData: スパンオブジェクトの配列[{ text, color? }]。各スパンはtextと、任意のカラートークンcolorを持ちます。
  • Returns: なし(void
  • 動作: スタイルテキストを設定すると、textプロパティより優先してレンダリングされます。

Example

textID.setStyledText([
{ text: "진행중 " },
{ text: `${count}`, color: "Label/highlight" },
{ text: "건" }
]);

clearStyledText

setStyledTextで適用したスタイルテキストを解除します。

  • Parameters: なし
  • Returns: なし(void

Example

textID.clearStyledText();

setTextStyle

テキストスタイルを一括設定します。

  • Parameters
    • style (string): テキストスタイルトークン(例: body1-medium
  • Returns: なし(void

Example

textID.setTextStyle("body1-medium");

Event

備考

該当なし — Textウィジェットには専用のEventがありません。

共通Widget Control(すべてのウィジェット)

注記

すべてのウィジェットは、setProperty(name, value) / getProperty(name) / setStyleProperty(styleName, styleProperty, value)のような共通Widget Control(Method)も使用できます。詳しいルールは共通Widget Controlリファレンスを参照してください。