master
BeniS 11 years ago
parent e7012031eb
commit 469df27d9b

@ -118,6 +118,10 @@ function UISpinBox:setValue(value)
signalcall(self.onValueChange, self, value) signalcall(self.onValueChange, self, value)
end end
function UISpinBox:getValue()
return self.value
end
function UISpinBox:setMinimum(minimum) function UISpinBox:setMinimum(minimum)
minimum = minimum or -9223372036854775808 minimum = minimum or -9223372036854775808
self.minimum = minimum self.minimum = minimum
@ -129,6 +133,10 @@ function UISpinBox:setMinimum(minimum)
end end
end end
function UISpinBox:getMinimum()
return self.minimum
end
function UISpinBox:setMaximum(maximum) function UISpinBox:setMaximum(maximum)
maximum = maximum or 9223372036854775807 maximum = maximum or 9223372036854775807
self.maximum = maximum self.maximum = maximum
@ -137,10 +145,10 @@ function UISpinBox:setMaximum(maximum)
end end
end end
function UISpinBox:setStep(step) function UISpinBox:getMaximum()
self.step = step or 1 return self.maximum
end end
function UISpinBox:getValue() function UISpinBox:setStep(step)
return self.value self.step = step or 1
end end

@ -591,12 +591,24 @@ function moveStackableItem(item, toPos)
spinbox:setValue(0) spinbox:setValue(0)
spinbox:hideButtons() spinbox:hideButtons()
spinbox:focus() spinbox:focus()
spinbox.firstEdit = true
local spinBoxValueChange = function(self, value) local spinBoxValueChange = function(self, value)
scrollbar:setValue(value) scrollbar:setValue(value)
end end
spinbox.onValueChange = spinBoxValueChange spinbox.onValueChange = spinBoxValueChange
local check = function()
if spinbox.firstEdit then
spinbox:setValue(spinbox:getMaximum())
spinbox.firstEdit = false
end
end
g_keyboard.bindKeyPress("Up", function() check() spinbox:up() end, spinbox)
g_keyboard.bindKeyPress("Down", function() check() spinbox:down() end, spinbox)
g_keyboard.bindKeyPress("PageUp", function() check() spinbox:setValue(spinbox:getValue()+10) end, spinbox)
g_keyboard.bindKeyPress("PageDown", function() check() spinbox:setValue(spinbox:getValue()-10) end, spinbox)
scrollbar.onValueChange = function(self, value) scrollbar.onValueChange = function(self, value)
itembox:setItemCount(value) itembox:setItemCount(value)
spinbox.onValueChange = nil spinbox.onValueChange = nil

Loading…
Cancel
Save