From fd672ac74e9e70dec122f1b0bb806cbd444d17c7 Mon Sep 17 00:00:00 2001 From: "kepler155c@gmail.com" Date: Sat, 9 Feb 2019 21:41:51 -0500 Subject: [PATCH] checkbox width bug, scroll canvas --- sys/apis/ui.lua | 15 +++++++++++---- sys/apis/ui/components/Checkbox.lua | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/sys/apis/ui.lua b/sys/apis/ui.lua index f9e8602..712b600 100644 --- a/sys/apis/ui.lua +++ b/sys/apis/ui.lua @@ -824,12 +824,19 @@ function UI.Window:scrollIntoView() parent:draw() end + -- TODO: fix + local function setOffset(y) + parent.offy = y + if parent.canvas then + parent.canvas.offy = parent.offy + end + parent:draw() + end + if self.y <= parent.offy then - parent.offy = math.max(0, self.y - 1) - parent:draw() + setOffset(math.max(0, self.y - 1)) elseif self.y + self.height > parent.height + parent.offy then - parent.offy = self.y + self.height - parent.height - 1 - parent:draw() + setOffset(self.y + self.height - parent.height - 1) end end diff --git a/sys/apis/ui/components/Checkbox.lua b/sys/apis/ui/components/Checkbox.lua index ac3ec4c..9f2c174 100644 --- a/sys/apis/ui/components/Checkbox.lua +++ b/sys/apis/ui/components/Checkbox.lua @@ -24,7 +24,7 @@ function UI.Checkbox:setParent() if not self.width and not self.ex then self.width = (self.label and #self.label or 0) + 3 else - self.widthh = 3 + self.width = 3 end UI.Window.setParent(self) end