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();
}
}