use layout() where appropriate and cleanup

This commit is contained in:
kepler155c@gmail.com
2020-04-09 16:08:54 -06:00
parent 8fe6e0806c
commit cd6ef0da50
14 changed files with 140 additions and 151 deletions

View File

@@ -41,14 +41,28 @@ end
function UI.DropMenu:enable()
local menuBar = self.parent:find(self.menuUid)
local hasActive
for _,c in pairs(self.children) do
if not c.spacer and menuBar then
c.inactive = not menuBar:getActive(c)
end
if not c.inactive then
hasActive = true
end
end
-- jump through a lot of hoops if all selections are inactive
-- there's gotta be a better way
-- lots of exception code just to handle drop menus
self.focus = not hasActive and function() end
UI.Window.enable(self)
self:focusFirst()
if self.focus then
self:setFocus(self)
else
self:focusFirst()
end
self:draw()
end
@@ -59,7 +73,7 @@ end
function UI.DropMenu:eventHandler(event)
if event.type == 'focus_lost' and self.enabled then
if not Util.contains(self.children, event.focused) then
if not (Util.contains(self.children, event.focused) or event.focused == self) then
self:disable()
end
elseif event.type == 'mouse_out' and self.enabled then