Thread Tools Display Modes
09-19-19, 10:19 PM   #1
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,906
Did you move your function or copy mine with the table wipes? The code I posted works here as is.

If you remove/comment out SLFG_RoleMenu_Init you should get a control with no drop list when you press the button.

Code:
function SFM_CreatePanel2()
    -- snipped
    dm = CreateFrame("Frame", "SFM_FromBox", f, "UIDropDownMenuTemplate")
        dm:SetPoint("LEFT", SFM_FromText, "RIGHT", -10, -2)
        dm:SetScale(.75)
        UIDropDownMenu_SetWidth(dm,105)
        UIDropDownMenu_Initialize(dm, SFM_FromDropInit)
    -- snipped
end
the
dm = CreateFrame("Frame", "SFM_FromBox", f, "UIDropDownMenuTemplate")
is inside a function that is proably called after the addon is fully loaded by which time
Code:
function SFM_FromDropInit(self)
will have been created.

To eliminate globals, change the test to:

Code:
local function ABC(self)

    local info = UIDropDownMenu_CreateInfo()
    
    info.text = "Tank"
    info.value = 0
    info.func = function(self)
        UIDropDownMenu_SetSelectedValue(self.owner, self.value)
--        SLFG_Settings.role = "TANK"
--        SLFG_UpdateMsg()
        end
    info.owner = self
    info.check = nil
    info.icon = nil
    UIDropDownMenu_AddButton(info)
    
    table.wipe(info)
    info.text = "Healer"
    info.value = 1
    info.func = function(self)
        UIDropDownMenu_SetSelectedValue(self.owner, self.value)
--        SLFG_Settings.role = "HEALER"
--        SLFG_UpdateMsg()
        end
    info.owner = self
    info.check = nil
    info.icon = nil
    UIDropDownMenu_AddButton(info)
    
    table.wipe(info)
    info.text = "DPS"
    info.value = 2
    info.func = function(self)
        UIDropDownMenu_SetSelectedValue(self.owner, self.value)
--        SLFG_Settings.role = "DPS"
--        SLFG_UpdateMsg()
        end
    info.owner = self
    info.check = nil
    info.icon = nil
    UIDropDownMenu_AddButton(info)
    
end

dm = CreateFrame("FRAME", "SLFG_RoleMenu", panel, "UIDropDownMenuTemplate")
dm:SetPoint("LEFT",  20, -2)
UIDropDownMenu_SetWidth(dm, 70)
UIDropDownMenu_Initialize(dm, ABC)
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 09-19-19 at 10:28 PM.
  Reply With Quote
09-19-19, 10:32 PM   #2
Sythalin
Curse staff
 
Sythalin's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 680
Originally Posted by Fizzlemizz View Post
Did you move your function or copy mine with the table wipes? The code I posted works here as is.

If you remove/comment out SLFG_RoleMenu_Init you should get a control with no drop list when you press the button.
I got it to work now (I forgot to add the table.wipe after each role step) and the dungeon list too. It's odd that it works in without table.wipe and order in CFM, but not in this. But at this point, I'm just glad it finally works so I can publish this thing. Thanks for your help!
  Reply With Quote
09-19-19, 10:40 PM   #3
Sythalin
Curse staff
 
Sythalin's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 680
Originally Posted by Fizzlemizz View Post
Did you move your function or copy mine with the table wipes? The code I posted works here as is.

snipped
That actually makes sense and something I didn't even consider. In SFM, the GUI is built in a seperate Lua from main file, so yeah, it's probably all loaded up before ADDON_LOADED fires (I'm not 100% savvy on the load vs. toc) whereas currently everything is in a single file in this project. Something I'll have to play with later to make sure I'm up to speed again.

This is what happens when one doesn't build/maintain mods for years in WoW.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » HELP: DropdownMenu issue


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