function ShowFrame_OnClick(frame)
-- frame:Show(); -- this will show all frames listed in the dropdownmenu as soon as i click
-- the minimap button, instead of showing the specified frame when i click on its name.
end
info = {};
info.text = "Discord Action Bars";
info.value = "DAB_Options";
info.notCheckable = 1;
info.func = ShowFrame_OnClick(DAB_Options);
UIDropDownMenu_AddButton(info);
|
What's happening is ShowFrame_OnClick(DAB_Options) runs, but only when it's assigned in the above initialization. ShowFrame_OnClick returns nil so info.func equals nil when the user gets around to clicking that dropdown button.
You'll want to do something like:
info.func = ShowFrame_OnClick
That will make info.func==the function instead of info.func==the result of the function
Of course you'll need to determine which option was chosen some other way. I have very little experience working with the default drop-downs so can't answer that part, but there's certainly a way.
edit: this is a clunky way to work around it. There's surely a smoother method:
info.func = function() ShowFrame_OnClick(DAB_Options) end
It wraps the function call around a function itself. You can also experiment with dropping the parameter to the function:
info.func = ShowFrame_OnClick
function ShowFrame_OnClick()
local id = this:GetID()
DEFAULT_CHAT_FRAME:AddMessage("You chose option "..id)
end