From b8276d35af753721b99e893d92485c99e2de111f Mon Sep 17 00:00:00 2001 From: ruki Date: Fri, 12 Jan 2018 00:39:22 +0800 Subject: add buttons to dialog --- tests/ui/dialog.lua | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'tests/ui/dialog.lua') diff --git a/tests/ui/dialog.lua b/tests/ui/dialog.lua index 7700eae8c..bf4f0ca0a 100644 --- a/tests/ui/dialog.lua +++ b/tests/ui/dialog.lua @@ -44,10 +44,19 @@ function demo:init() self:background_set("blue") -- init main dialog --- self:insert(dialog:new("dialog.main", rect {1, 1, self:width() - 1, self:height() - 1}, "main dialog")) + local dialog_main = dialog:new("dialog.main", rect {1, 1, self:width() - 1, self:height() - 1}, "main dialog") + dialog_main:button_add("ok", "< OK >", "cm_ok") + dialog_main:button_add("cancel", "< Cancel >", "cm_cancel") + dialog_main:button_add("help", "< Help >", "cm_help") + dialog_main:button_add("quit", "< Quit >", "cm_quit") + self:insert(dialog_main) -- init hello dialog - self:insert(dialog:new("dialog.hello", rect {0, 0, self:width() / 2, self:height() / 4}), {centerx = true, centery = true}) + local dialog_hello = dialog:new("dialog.hello", rect {0, 0, self:width() / 2, self:height() / 4}):background_set(dialog_main:frame():background()) + dialog_hello:frame():background_set("green") + dialog_hello:button_add("yes", "< Yes >", "cm_yes") + dialog_hello:button_add("no", "< No >", "cm_no") + self:insert(dialog_hello, {centerx = true, centery = true}) end -- main entry -- cgit v1.3.1