From 27fd2d36348e8060b57d98fe6f7c7c6f2bb23459 Mon Sep 17 00:00:00 2001 From: Kenny Shields Date: Sun, 6 May 2012 15:13:55 -0400 Subject: [PATCH] Fixed a bug that allowed tab buttons to potentially be scrolled infinitely --- objects/tabs.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/objects/tabs.lua b/objects/tabs.lua index dfc6265..08d0aa8 100644 --- a/objects/tabs.lua +++ b/objects/tabs.lua @@ -38,7 +38,7 @@ end function tabs:update(dt) local x, y = love.mouse.getPosition() - local tabheight = self.tabheight + local tabheight = self.tabheight local padding = self.padding local autosize = self.autosize local tabheight = self.tabheight @@ -160,6 +160,9 @@ function tabs:mousepressed(x, y, button) if col == true and visible == true then self.offsetx = self.offsetx + 5 + if self.offsetx > 0 then + self.offsetx = 0 + end end end @@ -172,6 +175,10 @@ function tabs:mousepressed(x, y, button) if col == true and visible == true then self.offsetx = self.offsetx - 5 + local bwidth = self:GetWidthOfButtons() + if (self.offsetx + bwidth) < self.width then + self.offsetx = bwidth - self.width + end end end