hotkeys use modifiers

This commit is contained in:
airstruck
2015-11-11 23:49:54 -05:00
parent 68a250e273
commit 6aaa128463
13 changed files with 205 additions and 113 deletions

View File

@@ -4,7 +4,7 @@ return function (self)
return value < 0 and 0 or value > 1 and 1 or value
end
self:setValue(clamp(self.value or 0.5))
self.value = clamp(self.value or 0.5)
self.step = self.step or 0.01
self.flow = 'x' -- TODO: support vertical slider
@@ -28,9 +28,9 @@ return function (self)
thumb:onKeyPress(function (event)
local key = event.key
if key == 'left' or key == 'down' then
self:setValue(clamp(self.value - self.step))
self.value = clamp(self.value - self.step)
elseif event.key == 'right' or key == 'up' then
self:setValue(clamp(self.value + self.step))
self.value = clamp(self.value + self.step)
end
end)
@@ -38,7 +38,7 @@ return function (self)
local x1, y1, x2, y2 = self:getRectangle(true, true)
local halfThumb = thumb:getWidth() / 2
x1, x2 = x1 + halfThumb, x2 - halfThumb
self:setValue(clamp((event.x - x1) / (x2 - x1)))
self.value = clamp((event.x - x1) / (x2 - x1))
thumb:focus()
end