From d9241acaa88b8c110b6e61017d39cff247ccd9d3 Mon Sep 17 00:00:00 2001 From: Qingping Hou Date: Wed, 25 Apr 2012 12:40:37 +0800 Subject: [PATCH] use TextBoxWidget in ConfirmBox also make text in bottons configurable --- dialog.lua | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/dialog.lua b/dialog.lua index c168f0852..222f9760c 100644 --- a/dialog.lua +++ b/dialog.lua @@ -124,17 +124,25 @@ Widget that shows a message and OK/Cancel buttons ]] ConfirmBox = FocusManager:new{ text = "no text", + width = nil, + ok_text = "OK", + cancel_text = "Cancel", } function ConfirmBox:init() + -- calculate box width on the fly if not given + if not self.width then + self.width = G_width - 200 + end + -- build bottons self.key_events.Close = { {{"Home","Back"}}, doc = "cancel" } self.key_events.Select = { {{"Enter","Press"}}, doc = "chose selected option" } local ok_button = Button:new{ - text = "OK" + text = self.ok_text, } local cancel_button = Button:new{ - text = "Cancel", + text = self.cancel_text, preselect = true } @@ -153,17 +161,18 @@ function ConfirmBox:init() HorizontalSpan:new{ width = 10 }, VerticalGroup:new{ align = "left", - TextWidget:new{ + TextBoxWidget:new{ text = self.text, - face = Font:getFace("cfont", 30) + face = Font:getFace("cfont", 30), + width = self.width, }, + VerticalSpan:new{ width = 10 }, HorizontalGroup:new{ ok_button, Widget:new{ dimen = { w = 10, h = 0 } }, cancel_button } } - } } }