Jump to content

Fix for ISTickBox when options have textures


NoctisFalco

Recommended Posts

An option's height is not recalculated when a texture is specified unlike in ISRadioButtons.

 

Steps to reproduce:

Create an ISTickBox UI element, add some options with textures: 

tickBox:addOption("option", data, texture)

ISTickBox_fix.png.318a03ca4b0d26deff7810313c9150f6.png

 

The fix is simple:

function ISTickBox:addOption(name, data, texture)
    table.insert(self.options, name);
    self.textures[self.optionCount] = texture;
    self.optionData[self.optionCount] = data;
    self.optionsIndex[self.optionCount] = name;
    self.optionCount = self.optionCount + 1;
    -- START OF FIX
    if texture then
        self.itemHgt = math.max(self.boxSize, self.fontHgt, self.textureSize) + self.itemGap
    end
    -- END OF FIX
    self:setHeight(#self.options * self.itemHgt);
    if self.autoWidth then
        local w = self.leftMargin + self.boxSize + self.textGap + getTextManager():MeasureStringX(self.font, name)
        if texture then
            w = w + 32;
        end
        if w > self:getWidth() then
            self:setWidth(w)
        end
    end
    return self.optionCount - 1;
end

-- And in the constructor
function ISTickBox:new(...)
    ...
    o.textureSize = 20
    ...
end

Just to be consistent with the ISRadioButtons widget.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...