From 1e17e4c29153e13cd2edfbf2f7539bf8a1e86e3d Mon Sep 17 00:00:00 2001 From: poire-z Date: Wed, 6 Sep 2017 12:56:50 +0200 Subject: [PATCH] Fix crash when tapping on toggleswitch left or bottom borders (#3181) --- frontend/ui/widget/toggleswitch.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/ui/widget/toggleswitch.lua b/frontend/ui/widget/toggleswitch.lua index bce536629..efc8b92b1 100644 --- a/frontend/ui/widget/toggleswitch.lua +++ b/frontend/ui/widget/toggleswitch.lua @@ -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)