From 839813768d1dece13a74964cceb712e2b2cff6bd Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Tue, 31 Aug 2021 18:30:28 +0200 Subject: [PATCH] fix: focus fix --- sonic-radiance.love/birb/modules/gui/mixins/elements.lua | 9 ++++++++- sonic-radiance.love/birb/modules/gui/screen.lua | 8 +++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/sonic-radiance.love/birb/modules/gui/mixins/elements.lua b/sonic-radiance.love/birb/modules/gui/mixins/elements.lua index 3bcffb6..0bf1511 100644 --- a/sonic-radiance.love/birb/modules/gui/mixins/elements.lua +++ b/sonic-radiance.love/birb/modules/gui/mixins/elements.lua @@ -46,7 +46,7 @@ function ElementList:elementExists(name) end function ElementList:haveFocus() - return self:elementExists(self.focusedElement) + return self:elementIsVisible(self.focusedElement) end function ElementList:getFocusedElement() @@ -81,4 +81,11 @@ function ElementList:getVisibleElement(topLayer) return visibleList end +function ElementList:elementIsVisible(name) + if (self:elementExists(name)) then + return self.elements[name]:getVisibility() + end + return false +end + return ElementList \ No newline at end of file diff --git a/sonic-radiance.love/birb/modules/gui/screen.lua b/sonic-radiance.love/birb/modules/gui/screen.lua index 3a2c08e..5ced2b2 100644 --- a/sonic-radiance.love/birb/modules/gui/screen.lua +++ b/sonic-radiance.love/birb/modules/gui/screen.lua @@ -80,18 +80,16 @@ function GuiScreen:registerElements() local elemData = utils.table.parse(rawElement, elementDataStruct, 3) local element = elemData.element self:addElement(element.name, element) + if (elemData.focus == true) then + element:getFocus() + end if (elemData.delay > 0) then element.isVisible = false element:newSwitch(elemData.delay, {"isVisible"}) - print(elemData.delay) end if (elemData.depth ~= nil) then element.depth = elemData.depth end - print(element, element.name, elemData.depth, elemData.focus) - if (elemData.focus == true) then - element:getFocus() - end if (elemData.keypress ~= nil) then element:setKeyPressAction(elemData.keypress) end