View Single Post
09-19-19, 10:19 PM   #10
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
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