package haxework.gui.popup; import haxework.net.callback.Callback; import haxework.net.callback.ICallback; import haxe.Timer; import haxework.provider.Provider; import haxework.dispath.Dispatcher; import haxework.dispath.IDispatcher; import haxework.gui.IGroupView; import haxework.gui.ButtonView; import haxework.gui.skin.ColorSkin; import haxework.gui.GroupView; class PopupView extends GroupView { private var buttonId:String; private var contentView:IGroupView; private var callback:ICallback; public function new(contentViewFactory:Class>) { super(); pWidth = 100; pHeight = 100; inLayout = false; skin = new ColorSkin(0x000000, 0.6); this.contentView = Type.createInstance(contentViewFactory, [{listener:this}]); addView(contentView); } public function onPress(button:ButtonView) { this.buttonId = button.id; close(); } public function show():ICallback { Provider.get(PopupManager).show(this); callback = Callback.build(); return callback; } public function close():Void { Provider.get(PopupManager).close(this); } public function onShow():Void { buttonId = "close"; } public function onClose():Void { if (callback != null) { callback.callSuccess(buttonId); callback = null; } } }