60 lines
1.4 KiB
D
60 lines
1.4 KiB
D
module simple.app;
|
||
|
||
import ncui;
|
||
|
||
import deimos.ncurses;
|
||
|
||
final class Simple : ScreenBase
|
||
{
|
||
override void ensureWindow(ScreenContext context)
|
||
{
|
||
int height = getmaxy(context.session.root());
|
||
int width = getmaxx(context.session.root());
|
||
|
||
_window = new Window(height, width, 0, 0);
|
||
}
|
||
|
||
override void layout(ScreenContext context, Window window, WidgetContainer ui)
|
||
{
|
||
_window.border();
|
||
_window.put(1, 2, "Пример простого скрина с кнопками");
|
||
}
|
||
|
||
override void build(ScreenContext context, Window window, WidgetContainer ui)
|
||
{
|
||
auto textIntput = new TextInput(5, 2, 10, "Hello");
|
||
// auto okBtn = new Button(3, 2, "OK", () => ScreenAction.push(new Simple()));
|
||
auto okBtn = new Button(3, 2, "OK", () {
|
||
textIntput.close();
|
||
return ScreenAction.quit(ScreenResult.none());
|
||
});
|
||
auto cancelBtn = new Button(3, 9, "Cancel", () => ScreenAction.pop(ScreenResult.none()));
|
||
|
||
auto disableOk = new Checkbox(4, 2,"Disable OK", false, (checked) {
|
||
okBtn.setEnabled(!checked);
|
||
});
|
||
|
||
_ui.add(okBtn);
|
||
_ui.add(cancelBtn);
|
||
_ui.add(disableOk);
|
||
_ui.add(textIntput);
|
||
}
|
||
|
||
override ScreenAction handleGlobal(ScreenContext context, KeyEvent event)
|
||
{
|
||
if (event.status == ERR)
|
||
{
|
||
return ScreenAction.quit(ScreenResult.none());
|
||
}
|
||
|
||
if (event.isChar)
|
||
{
|
||
if (event.ch == 27)
|
||
{
|
||
return ScreenAction.quit(ScreenResult.none());
|
||
}
|
||
}
|
||
|
||
return ScreenAction.none();
|
||
}
|
||
}
|