View Single Post
04/08/14, 05:44 PM   #29
Xrystal
caritas omnia vincit
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 369
It worked great with that little extra change.

The downside is that it must overwrite the font sizes so gonna try and get it run after the addon is loaded and see how different it works. But first screen shot shows it working as follows:

edit:

Well combined your two posts into the following piece of code so that you could create multiple combo boxes ( dropdowns ) in the same Top Level Window.

Lua Code:
  1. local wm = WINDOW_MANAGER
  2. local choices1 = {"alpha","beta","gamma","delta","epsilon","zita","ita","theta","iota","kappa","lambda","mu","nu","omicron","pi","rho","sigma","tau","ipsilon","omega"}
  3. local choices2 = {"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"}
  4.  
  5. local function CreateTopLevelWindow(name)
  6.     local tlw = wm:CreateTopLevelWindow(name)
  7.     tlw:SetAnchor(CENTER)
  8.     tlw:SetDimensions(200, 50)
  9.     return tlw
  10. end
  11.  
  12. local function CreateDropDown(name,parent,data,selected)
  13.     local combo = wm:CreateControlFromVirtual(parent:GetName()..name,parent,"ZO_StatsDropdownRow")
  14.     combo:SetAnchor(CENTER)
  15.     combo:GetNamedChild("Dropdown"):SetWidth(200)
  16.  
  17.     combo.selected = combo.name
  18.     combo.selected:SetFont("ZoFontGameLarge")
  19.  
  20.     combo.dropdown = combo.dropdown
  21.     combo.dropdown:SetFont("ZoFontGameLarge")
  22.     if selected then combo.dropdown:SetSelectedItem(selected) end
  23.  
  24.     combo.dropdown.OnSelect = function(self,value)
  25.         self:SetSelectedItem(value)
  26.     end
  27.  
  28.     for i = 1,#data do
  29.         local entry = combo.dropdown:CreateItemEntry(data[i],combo.dropdown.OnSelect)
  30.         combo.dropdown:AddItem(entry)
  31.     end
  32.     return combo
  33. end
  34.  
  35. local function AddOnLoaded(eventID,addon)
  36.     if addon ~= "ZO_ComboBoxTest" then return end
  37.     EVENT_MANAGER:UnregisterForEvent(addon,eventID)
  38.     local testTLW = CreateTopLevelWindow("ZO_ComboBoxTest_TLW")
  39.     testTLW:SetDimensions(200,120) 
  40.     local GreekAlphabet = CreateDropDown("GreekAlphabet",testTLW,choices1,"omega")
  41.     GreekAlphabet:SetAnchor(TOP)
  42.     local Weekdays = CreateDropDown("Weekdays",testTLW,choices2,"Sunday")
  43.     Weekdays:SetAnchor(BOTTOM)
  44. end
  45.  
  46. EVENT_MANAGER:RegisterForEvent( "ZO_ComboBoxTest" ,EVENT_ADD_ON_LOADED , AddOnLoaded )

2nd picture shows the 2 together on the screen.

edit 3:
But as you can see, the font still isn't letting you change it for some reason. Maybe you would have to make a template of the template and change the fonts at that point. But no biggie.
Attached Thumbnails
Click image for larger version

Name:	Screenshot_20140409_004156.jpg
Views:	647
Size:	364.0 KB
ID:	108  Click image for larger version

Name:	Screenshot_20140409_011016.jpg
Views:	686
Size:	426.1 KB
ID:	109  

Last edited by Xrystal : 04/08/14 at 06:14 PM.
  Reply With Quote