From 8d3f5329f25aa04082e7fbd5a86f39f46707d0fc Mon Sep 17 00:00:00 2001 From: "kepler155c@gmail.com" Date: Sun, 22 Oct 2017 01:30:26 -0400 Subject: [PATCH] misc --- sys/apis/ui.lua | 16 +++++++--------- sys/extensions/vfs.lua | 16 +--------------- 2 files changed, 8 insertions(+), 24 deletions(-) diff --git a/sys/apis/ui.lua b/sys/apis/ui.lua index ea8e2b7..3b59a22 100644 --- a/sys/apis/ui.lua +++ b/sys/apis/ui.lua @@ -135,11 +135,8 @@ function Manager:init() local ch = Input:translate('mouse_drag', button, x, y) if ch and self.target then local event = self:pointToChild(self.target, x, y) - - -- revisit - should send out scroll_up and scroll_down events - -- let the element convert them to up / down - self:inputEvent(event.element, - { type = ch, button = button, x = event.x, y = event.y }) + event.type = ch + self:inputEvent(event.element, event) self.currentPage:sync() end end) @@ -3026,14 +3023,15 @@ function UI.Form:createForm() for _, child in pairs(self) do if type(child) == 'table' and child.UIElement then if child.formKey then + child.value = self.values[child.formKey] or '' + end + if child.formLabel then child.x = self.labelWidth + self.margin - 1 child.y = y if not child.width and not child.ex then child.ex = -self.margin end - child.value = self.values[child.formKey] or '' - end - if child.formLabel then + table.insert(self.children, UI.Text { x = self.margin, y = y, @@ -3062,7 +3060,7 @@ end function UI.Form:validateField(field) if field.required then - if not field.value or #field.value == 0 then + if not field.value or #tostring(field.value) == 0 then return false, 'Field is required' end end diff --git a/sys/extensions/vfs.lua b/sys/extensions/vfs.lua index 67489c8..5283403 100644 --- a/sys/extensions/vfs.lua +++ b/sys/extensions/vfs.lua @@ -316,28 +316,14 @@ local function getNodeByParts(parts) end function fs.unmount(path) - local parts = splitpath(path) local targetName = table.remove(parts, #parts) local node = getNodeByParts(parts) - if not node or not node.nodes[targetName] then - error('Invalid node') - end - - node.nodes[targetName] = nil ---[[ - -- remove the shadow directories - while #parts > 0 do - targetName = table.remove(parts, #parts) - node = getNodeByParts(parts) - if not Util.empty(node.nodes[targetName].nodes) then - break - end + if node and node.nodes[targetName] then node.nodes[targetName] = nil end ---]] end function fs.registerType(name, fs)