I'm new to the world of addons and LUA/XML, and am looking for some insight regarding comboboxes. I want to use multiple comboboxes with the same entries, but I'm a bit confused as to how I should proceed. I can setup, display, and populate a combobox using (essentially) the code found in this thread:
http://www.esoui.com/forums/showpost...6&postcount=27. However, I don't think I want to repopulate a new combobox with the same info 8 times over (doesn't seem like good practice?).
I'm currently using XML to create a "base" combobox, then populating it via LUA code.
XML:
Code:
<Control name="myDropdown" inherits="ZO_ComboBox" virtual="true">
<OnInitialized>
ZO_ComboBox:New(self)
</OnInitialized>
</Control>
LUA:
Code:
local headArmorType = CreateControlFromVirtual("headArmorDropdown", MyWindow, "myDropdown")
headArmorType:SetDimensions(150, 30)
headArmorType:SetAnchor(TOPLEFT, MyWindow, TOPLEFT, 60, 120)
local choices = {"Light", "Medium", "Heavy"}
local dropdown = ZO_ComboBox_ObjectFromContainer(headArmorDropdown)
dropdown:SetSelectedItem("Armor Type")
dropdown:SetSortsItems(false)
local function OnItemSelect(_, choiceText, choice)
headArmorType = choiceText --I set the choice to a string variable in order to put it in a mail message
end
for i=1,#choices do
local entry = dropdown:CreateItemEntry(choices[i], OnItemSelect)
dropdown:AddItem(entry)
end
Would I want to create and populate a combobox with those entries (light, medium, heavy) in XML, then create instances of them in LUA? If that's the case, how would I build the table of choices in XML? (Or would I want to create a global variable or function in the LUA script, then reference/call it in the XML file in 'OnInitialized')?