use layout() where appropriate and cleanup
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user