From 68ead0c9b28258bc78ef4ba662a8b9a3ccba5285 Mon Sep 17 00:00:00 2001 From: Qingping Hou Date: Sun, 31 Jan 2016 14:25:21 -0800 Subject: [PATCH] feat(inputcontainer): support showing inputcontainer without content --- .../ui/widget/container/inputcontainer.lua | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/frontend/ui/widget/container/inputcontainer.lua b/frontend/ui/widget/container/inputcontainer.lua index db8230d15..0b40ad3d8 100644 --- a/frontend/ui/widget/container/inputcontainer.lua +++ b/frontend/ui/widget/container/inputcontainer.lua @@ -51,19 +51,21 @@ function InputContainer:_init() end function InputContainer:paintTo(bb, x, y) + if self[1] == nil then + return + end + if not self.dimen then local content_size = self[1]:getSize() self.dimen = Geom:new{w = content_size.w, h = content_size.h} end self.dimen.x = x self.dimen.y = y - if self[1] then - if self.vertical_align == "center" then - local content_size = self[1]:getSize() - self[1]:paintTo(bb, x, y + math.floor((self.dimen.h - content_size.h)/2)) - else - self[1]:paintTo(bb, x, y) - end + if self.vertical_align == "center" then + local content_size = self[1]:getSize() + self[1]:paintTo(bb, x, y + math.floor((self.dimen.h - content_size.h)/2)) + else + self[1]:paintTo(bb, x, y) end end @@ -97,6 +99,10 @@ function InputContainer:onGesture(ev) end function InputContainer:onInput(input) + if self.enter_callback == nil then + return + end + local InputDialog = require("ui/widget/inputdialog") self.input_dialog = InputDialog:new{ title = input.title or "",