Text Input Field appearing TINY when empty - help!

Hi all,

I honestly put some time into trying to figure this out myself (trial and error, API reference, Google) but I can’t figure this out.

I seem to have no control over how wide or tall my text box is, and most importantly, when I don’t put any default text inside, it shows up as a super tiny box that’s hard to even click into. Suddenly when I type into it, or start it off with any text, it has a more respectable, normal-looking manifestation.

Also feel free to point out any poor practices, I am still new! Thanks a lot.

Here is the current code (tried many configurations already…)

==================
AutosizeField.hx module (superfluous libraries are i nthere for now just 'cause)

package;

import openfl.display.Graphics;
import openfl.display.Sprite;
import openfl.events.MouseEvent;
import openfl.Lib;
import openfl.text.TextField;
import openfl.text.TextFormat;
import openfl.text.TextFieldType;
import openfl.text.TextFieldAutoSize;

class AutosizeField {

	public function new() {

        var autoField:TextField = new TextField();

        autoField.type = TextFieldType.INPUT;
        autoField.border = true;
        autoField.x = Lib.current.stage.stageWidth / 2;
	autoField.y = Lib.current.stage.stageHeight / 2;
        autoField.autoSize = TextFieldAutoSize.CENTER;
        autoField.text = "";
	Lib.current.stage.addChild(autoField);
	}
}

==================
Main.hx module

package;

import openfl.display.Graphics;
import openfl.display.Sprite;
import openfl.Lib;
import openfl.text.TextField;
import openfl.text.TextFormat;
import openfl.text.TextFieldType;

class Main extends Sprite {

public function new () {
	
	super ();
	
	init();
}

function init() {

var autoF = new AutosizeField();

}

}

Try putting in some text, then removing it:

autoField.text = "text";
autoField.text = "";
Lib.current.stage.addChild(autoField);

If that doesn’t work, you probably need to wait a frame before removing the text. To keep the user from noticing, start with space characters, or temporarily set the text color to match the background.

If that still doesn’t work, take a page from web forms, and start with “type your response here” or something. Then when the text field receives a click event, check if the text is still “type your response here,” and delete it if so.

Thanks for the suggestions, I’ll try them out and go with one of those if I need to. Isn’t it strange though if we’re forced into these kinds of workarounds? I don’t understand why the box is starting off so tiny. Aren’t I not just missing something?

I need it to start off with no text inside, so I can’t start off with “type here” etc.

Come on Haxe and OpenFL, I believe in you!

Have you tested it in Flash? If it acts differently there, it’s a bug and you could file a bug report.