2021-04-27 00:25:42 +02:00

51 lines
1.4 KiB
Haxe

package game.ui.console.elements;
import openfl.events.Event;
import openfl.display.Sprite;
import openfl.text.TextField;
import openfl.text.TextFieldType;
import openfl.text.TextFormat;
import openfl.Assets;
import game.ui.text.TextFormats;
class ConsoleInput extends Sprite
{
public var tf:TextField;
public function new(){
super();
tf = new TextField();
tf.defaultTextFormat = TextFormats.getFormats().cInputFmt;
tf.text = "";
//tf.setTextFormat(new TextFormat(Assets.getFont("fonts/Terminus.ttf").fontName, 24, 0x00ff00));
trace(tf.getTextFormat().color);
trace(tf.getTextFormat().font);
tf.type = TextFieldType.INPUT;
tf.multiline = false;
//tf.autoSize = TextFieldAutoSize.LEFT;
tf.width = 800-24;
tf.height = tf.textHeight+2;
tf.background = true;
tf.backgroundColor = 0x222222;
tf.selectable = true;
this.addChild(tf);
this.addEventListener(Event.RESIZE,onResize);
tf.addEventListener(Event.CHANGE, onTextChange);
}
public function onResize(e:Event){
tf.width = this.width;
}
public function onTextChange(e:Event){
}
public function clearText(){
tf.text = "";
}
public function getText():String
{
return tf.text;
}
public function setText(t:String){
tf.text = t;
}
}