Skip to content

Instantly share code, notes, and snippets.

@miahmie
Last active March 15, 2020 03:34
Show Gist options
  • Save miahmie/8189900ee082e8071905d1cebd82c9d4 to your computer and use it in GitHub Desktop.
Save miahmie/8189900ee082e8071905d1cebd82c9d4 to your computer and use it in GitHub Desktop.
標準のYesNoDialog/HistoryLayerのボタンのフォントサイズを変更する

標準のYesNoDialog/HistoryLayerのボタンのフォントサイズを変更する

標準の実装では特に指定がないため,カスタマイズにはTJSの知識が必要となります。

プラグインでの対応はコードが巨大になってしまいがちなので, 今回はシステム本体側にad-hocな修正を入れて対応してみます。

ButtonLayer.tjsをカスタマイズ

ButtonLayer.tjs property captionColor の定義の前に下記コードを追加してください。

	property captionSize {
		getter { return font.height; }
		setter(v) {     font.height = +v; update(); }
	}

	property captionFace {
		getter { return font.face; }
		setter(v) {     font.face = v; update(); }
	}

YesNoDialog.tjsをカスタマイズ

yesButton/noButtonを生成しているところにcaptionSizeを指定します。

		// Yesボタン
		add(yesButton = new ButtonLayer(this, primaryLayer));
		yesButton.caption = "はい";
		yesButton.captionSize = 24; // 追記
//...中略
		// Noボタン
		add(noButton = new ButtonLayer(this, primaryLayer));
		noButton.caption = "いいえ";
		noButton.captionSize = 24; // 追記

必要に応じて {yes,no}Button.captionFace = "フォントフェイス名"; を指定することもできます。

ダイアログのメッセージのフォントサイズを変更する場合は, primaryLayer.font.height を変更します。

		// サイズを決定
		primaryLayer.font.height = 24; // 追記
		var tw = primaryLayer.font.getTextWidth(message);
		var th = primaryLayer.font.getTextHeight(message);

HistoryLayer.tjsをカスタマイズ

同じようにボタンを生成しているところに指定します。

		prevPageButton = new LButtonLayer(window, this);
		nextPageButton = new LButtonLayer(window, this);
		closeButton = new LButtonLayer(window, this);

		// 個々に追記(verticalViewで分岐する前に一括で指定してしまう)
		prevPageButton.captionSize = 24;
		nextPageButton.captionSize = 24;
		closeButton.captionSize = 24;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment