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 | 種類 | シグネチャ | 説明 |
|---|---|---|---|
text | Property | string(読み取り/書き込み) | 表示するテキストの内容 |
orgText | Property | string(読み取り専用) | データバインディング前の元のテキスト |
color | Property | string(読み取り/書き込み) | 文字色 |
setText | Method | setText(s: string): void | テキストの内容を設定 |
setFontSize | Method | setFontSize(size: number): void | 文字サイズを設定 |
setTextColor | Method | setTextColor(color: string): void | 文字色を設定 |
setStyledText | Method | setStyledText(styledData): void | 複数のインラインスタイルが適用されたテキストを設定 |
clearStyledText | Method | clearStyledText(): void | スタイルテキストを解除 |
setTextStyle | Method | setTextStyle(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リファレンスを参照してください。