awtk/lua/demo2.lua

54 lines
1.0 KiB
Lua
Raw Normal View History

2018-03-10 08:06:02 +08:00
function on_click(ctx, evt)
print('on_click');
end
function application_init()
local win = Window.open("window1");
win.inc:on(EventType.CLICK, function(evt)
2018-04-08 07:32:48 +08:00
win.bar2:set_value(win.bar2.value + 10);
2018-03-10 08:06:02 +08:00
end);
win.dec:on(EventType.CLICK, function(evt)
2018-04-08 07:32:48 +08:00
win.bar2:set_value(win.bar2.value - 10);
2018-03-10 08:06:02 +08:00
end);
Timer.add(function()
2018-03-18 11:29:31 +08:00
if win.bar1.value <= 95 then
win.bar1:set_value(win.bar1.value + 5);
2018-03-31 13:48:18 +08:00
return Ret.REPEAT
2018-03-10 08:06:02 +08:00
end
2018-03-31 13:48:18 +08:00
return Ret.REMOVE
2018-03-10 08:06:02 +08:00
end, 500)
function show_dialog(name)
local dlg = Dialog.open(name)
2018-03-10 08:06:02 +08:00
dlg.client.ok:on(EventType.CLICK, function(evt)
2018-03-31 13:48:18 +08:00
print("ok clicked");
2018-03-10 08:06:02 +08:00
dlg:quit(0)
end);
dlg.client.cancel:on(EventType.CLICK, function(evt)
2018-03-31 13:48:18 +08:00
print("cancel clicked");
2018-03-10 08:06:02 +08:00
dlg:quit(1)
end);
dlg:modal()
dlg:destroy()
end
win.dialog:on(EventType.CLICK, function(evt)
show_dialog("dialog1");
end);
win.dialog2:on(EventType.CLICK, function(evt)
show_dialog("dialog2");
2018-03-10 08:06:02 +08:00
end);
end
application_init()