From AddOn devs for AddOn devs - Utility functions

From ESOUI Wiki

Jump to: navigation, search

Sample Functions

Feel free to put any useful functions you've found or created here. Please make them readable, or comment them so users can understand what's happening.


UI Functions

-- This function takes in the control you wish to add a toggle to, two textures for ON and OFF states, and an optional initial value.
-- control:toggle() is a new function added to the control, that can be called to change the toggle.
-- GetToggle() and SetToggle could also be added, if required, using similar function construction
local function createToggle(control, onTexture, offTexture, initialToggleValue)
    control.toggleValue = initialToggleValue or true
    function control:toggle()
        if self.toggleValue then
            self.toggleValue = false
            self:SetNormalTexture(offTexture)
        else
            self.toggleValue = true
            self:SetNormalTexture(onTexture)
        end
    end
end

Helper Functions

Personal tools
Namespaces
Variants
Actions
Menu
Wiki
Toolbox