I'm a beginner programmer, but I just did something like that in my addon "hebChat". I wasn't aware of Ace3 or other libs, so I did it as a standalone code. In my addon I divided the code into XML and LUA.
This is how it looks like:
XML:
Code:
<Frame name="$parent_dropDownList" parentKey="dropDownList" inherits="UIDropDownMenuTemplate">
<Anchors>
<Anchor point="LEFT" relativePoint="RIGHT" relativeTo="$parent_dropDownFont">
<Offset x="-3" y="-3"/>
</Anchor>
</Anchors>
<Size x="250"/>
<Scripts>
<OnLoad>
hebChatDropDownList_OnLoad(self)
UIDropDownMenu_SetWidth(self, 150)
UIDropDownMenu_SetButtonWidth(self, 174)
UIDropDownMenu_JustifyText(self, "CENTER")
</OnLoad>
</Scripts>
</Frame>
LUA:
Code:
-- Fonts table
hebChat.fonts = {
["Default Font"] = {"No Hebrew", "Fonts\\ARIALN.TTF"},
["Arial"] = {"תירבע", "Interface\\AddOns\\hebChat\\Fonts\\arial.ttf"},
["Tahoma"] = {"תירבע", "Interface\\AddOns\\hebChat\\Fonts\\tahoma.ttf"},
["Times New Roman"] = {"תירבע", "Interface\\AddOns\\hebChat\\Fonts\\times.ttf"},
["Sans Serif"] = {"תירבע", "Interface\\AddOns\\hebChat\\Fonts\\micross.ttf"},
["Miriam"] = {"תירבע", "Interface\\AddOns\\hebChat\\Fonts\\mriam.ttf"},
["Courier"] = {"תירבע", "Interface\\AddOns\\hebChat\\Fonts\\courbd.ttf"},
["David"] = {"תירבע", "Interface\\AddOns\\hebChat\\Fonts\\david.ttf"},
["David Bold"] = {"תירבע", "Interface\\AddOns\\hebChat\\Fonts\\davidbd.ttf"},
["FrankRuehl"] = {"תירבע", "Interface\\AddOns\\hebChat\\Fonts\\frank.ttf"},
["Levenim"] = {"תירבע", "Interface\\AddOns\\hebChat\\Fonts\\lvnm.ttf"},
["Narkisim"] = {"תירבע", "Interface\\AddOns\\hebChat\\Fonts\\nrkis.ttf"},
["Gisha"] = {"תירבע", "Interface\\AddOns\\hebChat\\Fonts\\gisha.ttf"},
}
-- Font Objects table
hebChat.fObjects = {}
-- Create font objects
function hebChat:createFontObjects()
local fObject = nil
for k, v in pairs(self.fonts) do
fObject = CreateFont(k)
fObject:SetFont(v[2], 13)
self.fObjects[k] = fObject
end
end
-- Selecting a font from dropdown list
local function hebChatDropDownList_OnClick(self, arg1)
if (hebChatDB.globalEn) then
hebChatDB.hebFont = arg1
hebChatDB.currentFont = arg1
else
hebChatDB.defaultFont = arg1
hebChatDB.currentFont = arg1
end
hebChat:setChatFont()
UIDropDownMenu_SetText(hebChatConfigPanel.dropDownList, hebChatDB.currentFont)
end
-- Initialize fonts dropdown list
local function hebChatInitializeDropDown(self, level)
local info = UIDropDownMenu_CreateInfo()
for k, v in pairs(hebChat.fonts) do
wipe (info)
info.text = k.." "..v[1]
--info.keepShownOnClick = true
--info.isNotRadio = true
info.arg1 = k
info.func = hebChatDropDownList_OnClick
info.checked = hebChatIsCurrentFont(k)
info.fontObject = hebChat.fObjects[k]
UIDropDownMenu_AddButton(info)
end
end
function hebChatDropDownList_OnLoad(self)
UIDropDownMenu_Initialize(self, hebChatInitializeDropDown)
end