import openfl.text.TextField;
import openfl.display.Sprite;

class NewForm extends Sprite {
	public function new(cb:Int->Int->Void) {
		super();

		var btn = new Button('New');
		addChild(btn);

		var widthInput = new TextField();
		widthInput.x = btn.width + 10;
		widthInput.border = true;
		widthInput.height = btn.height;
		widthInput.width = 50;
		widthInput.type = INPUT;
		widthInput.text = '10';
		addChild(widthInput);

		var heightInput = new TextField();
		heightInput.x = widthInput.x + widthInput.width + 10;
		heightInput.border = true;
		heightInput.height = btn.height;
		heightInput.width = 50;
		heightInput.type = INPUT;
		heightInput.text = '10';
		addChild(heightInput);

		btn.action = () -> {
			cb(Std.parseInt(widthInput.text), Std.parseInt(heightInput.text));
		};
	}
}
