Added styling option for UISpinBox buttons.

master
BeniS 12 years ago
parent 0c5479b031
commit 9c497f72f9

@ -4,6 +4,7 @@ UISpinBox = extends(UITextEdit)
function UISpinBox.create()
local spinbox = UISpinBox.internalCreate()
spinbox:setValidCharacters('0123456789')
spinbox.displayButtons = true
spinbox.minimum = 0
spinbox.maximum = 0
spinbox.value = 0
@ -50,15 +51,33 @@ end
function UISpinBox:onStyleApply(styleName, styleNode)
for name, value in pairs(styleNode) do
if name == 'maximum' then
addEvent(function() self:setMaximum(value)
end)
addEvent(function() self:setMaximum(value) end)
elseif name == 'minimum' then
addEvent(function() self:setMinimum(value)
end)
addEvent(function() self:setMinimum(value) end)
elseif name == 'buttons' then
addEvent(function()
if value then
self:showButtons()
else
self:hideButtons()
end
end)
end
end
end
function UISpinBox:showButtons()
self:getChildById('up'):show()
self:getChildById('down'):show()
self.displayButtons = true
end
function UISpinBox:hideButtons()
self:getChildById('up'):hide()
self:getChildById('down'):hide()
self.displayButtons = false
end
function UISpinBox:up()
self:setValue(self.value + 1)
end

@ -149,6 +149,7 @@ Panel
anchors.left: prev.right
margin-left: 3
width: 55
buttons: false
minimum: 1
maximum: 64000

Loading…
Cancel
Save