2022-02-22 00:48:31 +00:00
|
|
|
import haxe.MainLoop;
|
2022-02-21 00:50:19 +00:00
|
|
|
import kernel.Init;
|
2022-02-20 19:56:37 +00:00
|
|
|
import lib.ui.Observable;
|
2021-12-20 00:55:30 +00:00
|
|
|
import lib.ui.TextElement;
|
|
|
|
import lib.ui.ReactiveUI;
|
|
|
|
import kernel.ui.WindowManager;
|
|
|
|
import kernel.KernelEvents;
|
|
|
|
|
|
|
|
using util.Extender.LambdaExtender;
|
|
|
|
|
|
|
|
class Startup {
|
2022-02-21 00:50:19 +00:00
|
|
|
public static function main() {
|
|
|
|
Init.initKernel();
|
2021-12-20 00:55:30 +00:00
|
|
|
|
2022-02-22 00:48:31 +00:00
|
|
|
MainLoop.add(() -> {
|
|
|
|
KernelEvents.instance.startEventLoop();
|
|
|
|
},0);
|
2021-12-20 00:55:30 +00:00
|
|
|
|
2022-02-22 00:48:31 +00:00
|
|
|
exampleUI();
|
2021-12-20 00:55:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static function exampleUI() {
|
|
|
|
var context = WindowManager.instance.createNewContext();
|
|
|
|
|
2022-02-20 19:56:37 +00:00
|
|
|
var text = new Observable("Hello world");
|
|
|
|
|
|
|
|
var ui = new ReactiveUI(context,[
|
|
|
|
new TextElement(text),
|
|
|
|
new TextElement(text,Green,Red),
|
2021-12-20 00:55:30 +00:00
|
|
|
]);
|
|
|
|
|
2022-02-20 19:56:37 +00:00
|
|
|
ui.render();
|
2022-02-22 00:48:31 +00:00
|
|
|
|
2022-02-21 00:50:19 +00:00
|
|
|
context.clickSignal.handle(data -> {
|
2022-02-20 19:56:37 +00:00
|
|
|
text.set("Holla mundo");
|
|
|
|
});
|
|
|
|
|
2021-12-20 00:55:30 +00:00
|
|
|
WindowManager.instance.focusContextToOutput(context,"main");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|