From 81d733d269a2b9ec92a24b396eb2ae8a10203f37 Mon Sep 17 00:00:00 2001 From: Qingping Hou Date: Sat, 28 Apr 2012 11:49:38 +0800 Subject: [PATCH] fix bug in TextBoxWidget shrink box width if text is shorter than one line. --- widget.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/widget.lua b/widget.lua index b7046ae7b..e68e681ca 100644 --- a/widget.lua +++ b/widget.lua @@ -256,15 +256,19 @@ function TextBoxWidget:_render() local h = (font_height + line_height_px) * #v_list - line_height_px self._bb = Blitbuffer.new(self.width, h) local y = font_height - + local pen_x = 0 for _,l in ipairs(v_list) do - local pen_x = 0 + pen_x = 0 for _,w in ipairs(l) do renderUtf8Text(self._bb, pen_x, y, self.face, w.word, true) pen_x = pen_x + w.width + space_w end y = y + line_height_px + font_height end + -- if text is only one line, shrink to text's width + if #v_list == 1 then + self.width = pen_x + end end function TextBoxWidget:getSize()