From d7ceaa1506f96f5e506a36de4f85d2cb2c1b3091 Mon Sep 17 00:00:00 2001 From: Ian Harrigan Date: Tue, 13 Feb 2024 10:51:22 +0100 Subject: [PATCH] flash fixes... flash?!?! --- haxe/ui/backend/TextDisplayImpl.hx | 16 ++++++++++++++-- haxe/ui/backend/TextInputImpl.hx | 12 ++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/haxe/ui/backend/TextDisplayImpl.hx b/haxe/ui/backend/TextDisplayImpl.hx index 76ad7a0..45f9b22 100644 --- a/haxe/ui/backend/TextDisplayImpl.hx +++ b/haxe/ui/backend/TextDisplayImpl.hx @@ -36,6 +36,14 @@ class TextDisplayImpl extends TextBase { tf.selectable = false; tf.mouseEnabled = false; tf.autoSize = TextFieldAutoSize.LEFT; + + #if flash + var format:TextFormat = tf.getTextFormat(); + format.font = "_sans"; + format.size = 13; + tf.defaultTextFormat = format; + #end + #if cache_text_metrics var format:TextFormat = tf.getTextFormat(); format.font = "_sans"; @@ -107,7 +115,9 @@ class TextDisplayImpl extends TextBase { } textField.defaultTextFormat = format; - //textField.setTextFormat(format); + #if flash + textField.setTextFormat(format); + #end if (textField.wordWrap != _displayData.wordWrap) { textField.wordWrap = _displayData.wordWrap; measureTextRequired = true; @@ -185,6 +195,7 @@ class TextDisplayImpl extends TextBase { #else _textWidth = textField.textWidth - 2; #end + _textHeight = textField.textHeight; if (_textHeight == 0) { var tmpText:String = textField.text; @@ -192,10 +203,11 @@ class TextDisplayImpl extends TextBase { _textHeight = textField.textHeight; textField.text = tmpText; } + #if !flash //_textHeight += PADDING_Y; #else - _textHeight += 2; + //_textHeight += 2; #end _textWidth = Math.round(_textWidth); diff --git a/haxe/ui/backend/TextInputImpl.hx b/haxe/ui/backend/TextInputImpl.hx index 7a6212e..48aa88c 100644 --- a/haxe/ui/backend/TextInputImpl.hx +++ b/haxe/ui/backend/TextInputImpl.hx @@ -6,6 +6,7 @@ import openfl.events.Event; import openfl.text.TextField; import openfl.text.TextFieldAutoSize; import openfl.text.TextFieldType; +import openfl.text.TextFormat; class TextInputImpl extends TextDisplayImpl { public function new() { @@ -28,6 +29,13 @@ class TextInputImpl extends TextDisplayImpl { tf.multiline = true; tf.wordWrap = true; + #if flash + var format:TextFormat = tf.getTextFormat(); + format.font = "_sans"; + format.size = 13; + tf.defaultTextFormat = format; + #end + return tf; } @@ -158,6 +166,10 @@ class TextInputImpl extends TextDisplayImpl { #end super.measureText(); + #if flash + _textHeight += 2; + #end + #if openfl_textfield_workarounds // not required for alot of apps, or later versions of openfl if (StringTools.endsWith(_text, "\n")) { _textHeight += textField.getLineMetrics(textField.numLines - 2).height;