LibAddonMenu: Example how to update dropdown box entries

From ESOUI Wiki

Jump to: navigation, search

Examples can be found here: https://www.esoui.com/forums/showthread.php?t=9581

You need to gve your dropdown box LAM settings control a "reference" tag.
The reference is defining a name for that control so that you are able to find it in the global table _G.
After you have defined the reference you can use <referenceVariable>:UpdateChoices(listOfChoices) on the dropdown box, to update it's entries.


           --LAM dropdown box example with reference
                {
                    type = 'dropdown',
                    name = "Test dropdown",
                    tooltip = "Test dropdown tooltip",
                    choices = { [1] = "Entry 1", [2] = "Entry 2" },
                    choicesValues = { [1] = 1, [2] = 2 },
                    choicesTooltips = { [1] = "Entry 1 tooltip", [2] = "Entry 2 tooltip" },
                    scrollable = true,
                    getFunc = function() return settings.testDropdownEntryChosen
                    end,
                    setFunc = function(value)
                        settings.testDropdownEntryChosen= value
                    end,
                    default = defaultSettings.testDropdownEntryChosen,
                    reference = "MyAddonName_Test_Dropdown",
                    disabled = function() return MyAddonName.isLAMControlDisabled("testDropdownEntryChosen") end,
                },
   --If you want to update the dropdown entries now you can use the reference variable MyAddonName_Test_Dropdown (which is == _G["MyAddonName_Test_Dropdown"])
   --->  <LAMDropdownControl>:UpdateChoices(choices, choicesValues, choicesTooltips)
   MyAddonName_Test_Dropdown:UpdateChoices({ [1] = "Entry 1", [2] = "Entry 2", [3] = "Entry 3" }, { [1] = 1, [2] = 2, [3] = 4, }, { [1] = "Entry 1 tooltip", [2] = "Entry 2 tooltip" }, [3] = "Entry 3 tooltip" })


Attention: MyAddonName_Test_Dropdown will not be given before the LAM settings menu was created! And this will not be the case at EVENT_ADD_ON_LOADED or EVENT_PLAYER_ACTIVATED but after the first time the LAM settings panels were opened.
Example how to check that your addon's panel & it's controls have been created: https://wiki.esoui.com/LibAddonMenu:_Example_how_to_detect_panel_controls_created


Other LAM example: https://wiki.esoui.com/LibAddonMenu:_Example_how_to_detect_panel_Show/Hide
LibAddonMenu WIKI / Documentation: https://github.com/sirinsidiator/ESO-LibAddonMenu/wiki/Exposed-Methods-on-LAM2

Personal tools
Namespaces
Variants
Actions
Menu
Wiki
Toolbox