LibAddonMenu: Example how to detect panel controls created

From ESOUI Wiki

Jump to: navigation, search

If you want to do something as your addon's settings panel has created it's controls ("is ready") you can use a callback of LibAddonMenu2.

local myAddonName = MyAddonGLobalVariable local addonVars = myAddonName.addonVariables local LAMpanelData = {

       type 		    = 'panel',
       name 		    = addonVars.addonNameMenu,
       displayName 	    = addonVars.addonNameMenuDisplay,
       author 		    = addonVars.addonAuthor,
       version 	    = addonVars.addonVersionOptions,
       registerForRefresh  = true,
       registerForDefaults = true,
       slashCommand 	    = "/myaddonsettings",
       website             = addonVars.website,
       feedback            = addonVars.websiteFeedback,
       donation            = addonVars.donation,   

} --Do not use the same name as your SavedVariables or your global table here, else it will be overwritten by LibAddonMenu. The name parameter for the panel needs to be unique, that's why we add the suffix "_LAM" myAddonName.LAMSettingsPanel = LibAddonMenu2:RegisterAddonPanel(myAddonName.addonName .. "_LAM", LAMpanelData)

local function LAMPanelCreated(panel)

 if panel ~= myAddonName.LAMSettingsPanel then return end
 --Your addon's LAM panel controls have been created. You can now use the "reference" tags of the controls that have been created her to e.g. UpdateChoices etc.
 

end

local optionsTable = {

---LAM options like description, dropdown, iconpicker etc. here

}

cm:RegisterCallback("LAM-PanelControlsCreated", LAMPanelCreated) --The name parameter here, with the _LAM suffix, needs to be the same as used above at the function "RegisterAddonPanel"! LibAddonMenu2:RegisterOptionControls(myAddonName.addonName .. "_LAM", optionsTable)

Personal tools
Namespaces
Variants
Actions
Menu
Wiki
Toolbox