diff options
author | Aki <nthirtyone@gmail.com> | 2016-08-24 00:10:33 +0200 |
---|---|---|
committer | Aki <nthirtyone@gmail.com> | 2016-08-24 00:10:33 +0200 |
commit | cd72b080bd949d9ec0b42c29e0ea31e300464dad (patch) | |
tree | 3e1e7a0314ad43dfa96868c04060df82997bed74 | |
parent | 9b8f5e3d356be281d8ef25227b087bb99b07b58d (diff) | |
download | roflnauts-cd72b080bd949d9ec0b42c29e0ea31e300464dad.zip roflnauts-cd72b080bd949d9ec0b42c29e0ea31e300464dad.tar.gz roflnauts-cd72b080bd949d9ec0b42c29e0ea31e300464dad.tar.bz2 |
Focus() return bool
-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 |