Skip to content

Commit

Permalink
flash fixes... flash?!?!
Browse files Browse the repository at this point in the history
  • Loading branch information
ianharrigan committed Feb 13, 2024
1 parent ee90746 commit d7ceaa1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
16 changes: 14 additions & 2 deletions haxe/ui/backend/TextDisplayImpl.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -185,17 +195,19 @@ class TextDisplayImpl extends TextBase {
#else
_textWidth = textField.textWidth - 2;
#end

_textHeight = textField.textHeight;
if (_textHeight == 0) {
var tmpText:String = textField.text;
textField.text = "|";
_textHeight = textField.textHeight;
textField.text = tmpText;
}

#if !flash
//_textHeight += PADDING_Y;
#else
_textHeight += 2;
//_textHeight += 2;
#end

_textWidth = Math.round(_textWidth);
Expand Down
12 changes: 12 additions & 0 deletions haxe/ui/backend/TextInputImpl.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit d7ceaa1

Please sign in to comment.