awtk/lua/button.lua

33 lines
760 B
Lua
Raw Normal View History

2018-03-04 08:32:52 +08:00
function on_click(ctx, evt)
print('on_click');
end
function application_init()
local win = Window.create(NULL, 0, 0, 0, 0);
ok = Button.create(win, 10, 5, 80, 30);
ok:set_text(to_wstr("ok"));
print(ok, getmetatable(ok));
label = Label.create(win, 100, 5, 80, 30);
label:set_text(to_wstr("text"));
print(ok, getmetatable(ok));
print(label, getmetatable(label));
rid = ok:on(EventType.EVT_CLICK, function(evt)
print(ok, getmetatable(ok));
print(evt, getmetatable(evt));
local e = PointerEvent.cast(evt);
print(ok, getmetatable(ok));
print(e, getmetatable(e));
print("on click:" .. tostring(e.x) .. " " .. tostring(e.y))
2018-03-04 13:09:23 +08:00
ok:off(rid)
2018-03-04 08:32:52 +08:00
return Ret.OK;
end);
print(tostring(rid))
end
application_init()