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

pull/3183/head
poire-z 7 years ago committed by Frans de Jonge
parent 12af617b46
commit 1e17e4c291

@ -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)

Loading…
Cancel
Save