diff options
-rw-r--r-- | button.lua | 1 | ||||
-rw-r--r-- | element.lua | 8 | ||||
-rw-r--r-- | header.lua | 8 | ||||
-rw-r--r-- | menu.lua | 8 |
4 files changed, 11 insertions, 14 deletions
@@ -34,6 +34,7 @@ end function Button:getPosition() return self.x,self.y end function Button:focus(next) self.focused = true + return true end function Button:blur() self.focused = false diff --git a/element.lua b/element.lua index 5ca013b..f9d1c3d 100644 --- a/element.lua +++ b/element.lua @@ -26,12 +26,8 @@ function Element:set(name, func) end -- Menu callbacks -function Element:focus(next) -- Called when Element gains focus - if next and self.parent then - self.parent:next() - else - self.parent:previous() - end +function Element:focus() -- Called when Element gains focus + return false end function Element:blur() end -- Called when Element loses focus @@ -29,12 +29,8 @@ function Header:getBounce(f) return math.sin(self.bounce*f*math.pi) end function Header:getPosition() return self.x,self.y end -- gives x,y of Element -function Header:focus(next) - if next and self.parent then - self.parent:next() - else - self.parent:previous() - end +function Header:focus() + return false end function Header:blur() end -- Called when Element loses focus @@ -34,7 +34,9 @@ end function Menu:next() self.elements[self.active]:blur() self.active = (self.active%#self.elements)+1 - self.elements[self.active]:focus(true) + if not self.elements[self.active]:focus() then + self:next() + end end function Menu:previous() self.elements[self.active]:blur() @@ -43,7 +45,9 @@ function Menu:previous() else self.active = self.active - 1 end - self.elements[self.active]:focus() + if not self.elements[self.active]:focus() then + self:previous() + end end -- LÖVE2D callbacks |