Thread Tools Display Modes
07-29-17, 06:32 AM   #1
Mortimerlol
A Cliff Giant
AddOn Author - Click to view addons
Join Date: Jul 2017
Posts: 71
Problem with UIDropDownMenu_SetSelectedID [SOLVED]

Helloooo,

I'm doing a dropdownmenu with names loaded from savedvariable, all is fine but I can't select name, when select name... crash.
Lua Code:
  1. -- CONTENIDO SELECTOR HATE LIST
  2. local function initialize(self, level)
  3. local toSort = {}
  4. for k in pairs(BangCharHateds) do toSort[#toSort + 1] = k end
  5. table.sort(toSort)
  6. --for i = 1, #toSort do print(toSort[i]) end
  7.  
  8. local function OnSelect(self, event, ...)
  9.     UIDropDownMenu_SetSelectedID(self, self:GetID(info))
  10. end
  11.  
  12. local info=UIDropDownMenu_CreateInfo()
  13.     for k,v in pairs(toSort) do
  14.         info=UIDropDownMenu_CreateInfo()
  15.         info.text=v
  16.         info.value=v
  17.         info.func=OnSelect
  18.         UIDropDownMenu_AddButton(info, level)
  19.     end
  20. end
  21.  
  22. local function Init(btn)
  23.     UIDropDownMenu_Initialize(btn, initialize)
  24.     UIDropDownMenu_SetWidth(btn, 120)
  25.     UIDropDownMenu_SetButtonWidth(btn, 124)
  26.     UIDropDownMenu_SetSelectedID(btn, 1)
  27.     UIDropDownMenu_JustifyText(btn, "LEFT")
  28. end
  29.  
  30. Init(delenemy)
Need this list to select a name for deleting button...
Lua Code:
  1. Gui.func3frame.list = CreateFrame("Button", "delenemy", Gui.func3frame, "UIDropDownMenuTemplate")
  2.  Gui.func3frame.list:SetPoint("CENTER", -35, -12)
  3. --
  4. Gui.func3frame.del = CreateFrame("Button", "delenemy", Gui.func3frame, "UIPanelButtonTemplate")
  5. Gui.func3frame.del:SetSize(50,22)
  6. Gui.func3frame.del:SetPoint("CENTER", 70, -10)
  7. Gui.func3frame.del:SetText("Del")
  8. Gui.func3frame.del:SetScript("OnClick", function(self, delenemy)
  9.     BangCharHateds[self:GetParent().delenemy] = BangCharHateds[self:GetParent().delenemy] and BangCharHateds[self:GetParent().delenemy] + 1 or false;
  10.     print("|cff009900- Deleted |r" ..self:GetParent().delenemy.." |cff009900to hate list.")
  11. end)

Last edited by Mortimerlol : 07-29-17 at 10:34 AM.
  Reply With Quote
07-29-17, 06:41 AM   #2
Mortimerlol
A Cliff Giant
AddOn Author - Click to view addons
Join Date: Jul 2017
Posts: 71
change linea 9 : UIDropDownMenu_SetSelectedID(self, self:GetID(info))

for UIDropDownMenu_SetSelectedID(delenemy, self:GetID(info))

Now I can select a name in the list
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Problem with UIDropDownMenu_SetSelectedID [SOLVED]


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off