local function Slider(name) local base = Object(name) local objectType = "Slider" base.width = 8 base.bgColor = colors.lightGray base.fgColor = colors.gray base:setValue(1) local barType = "horizontal" local symbol = " " local symbolColor = colors.black local bgSymbol = "\140" local maxValue = base.width local index = 1 local object = { getType = function(self) return objectType end; setSymbol = function(self, _symbol) symbol = _symbol:sub(1, 1) self:setVisualChanged() return self end; setBackgroundSymbol = function(self, _bgSymbol) bgSymbol = string.sub(_bgSymbol, 1, 1) self:setVisualChanged() return self end; setSymbolColor = function(self, col) symbolColor = col self:setVisualChanged() return self end; setBarType = function(self, _typ) barType = _typ:lower() return self end; mouseClickHandler = function(self, event, button, x, y) if (base.mouseClickHandler(self, event, button, x, y)) then local obx, oby = self:getAbsolutePosition(self:getAnchorPosition()) if (barType == "horizontal") then for _index = 0, self.width - 1 do if (obx + _index == x) and (oby <= y) and (oby + self.height > y) then index = _index + 1 self:setValue(maxValue / self.width * (index)) self:setVisualChanged() end end end if (barType == "vertical") then for _index = 0, self.height - 1 do if (oby + _index == y) and (obx <= x) and (obx + self.width > x) then index = _index + 1 self:setValue(maxValue / self.height * (index)) self:setVisualChanged() end end end --[[if(event=="mouse_scroll")then self:setValue(self:getValue() + (maxValue/(barType=="vertical" and self.height or self.width))*typ) self:setVisualChanged() end if(self:getValue()>maxValue)then self:setValue(maxValue) end if(self:getValue()