Fix crash when tapping on toggleswitch left or bottom borders (#3181)

This commit is contained in:
poire-z authored and Frans de Jonge committed 2017-09-06 12:56:50 +02:00
1 parent 12af617b46
commit 1e17e4c291
1 file changed
+1 -1
+1 -1
View File
@@ -142,7 +142,7 @@ end
function ToggleSwitch:calculatePosition(gev)
local x = (gev.pos.x - self.dimen.x) / self.dimen.w * self.n_pos
local y = (gev.pos.y - self.dimen.y) / self.dimen.h * self.row_count
return math.ceil(x) + math.floor(y) * self.n_pos
return math.max(1, math.ceil(x)) + math.min(self.row_count-1, math.floor(y)) * self.n_pos
end
function ToggleSwitch:onTapSelect(arg, gev)