View Single Post
10-24-18, 01:54 PM   #1
Diavol
A Defias Bandit
Join Date: Jul 2012
Posts: 2
Adding button to the menu

Hi guys, I have a problem with adding button to the menu.
There are a lot of tips how to do it but most of them don't work (idk why).
I found in this addon https://www.wowinterface.com/downloa...AddFriend.html and its code is working.
Code:
AFriend = LibStub("AceAddon-3.0"):NewAddon("AFriend", "AceHook-3.0");
local AFriend = AFriend;
local AFriendButtons = {};
local AfriendMenu = {};
local AButtons = "QR_code";
local AButtonTxt = "QR code";
local AToolTips = "Generate QR code";
local redColor, greenColor = "|cffff2020", "|cff20ff20";
local gsub, ipairs = gsub, ipairs;
local UnitGUID, UnitName, UnitCanCooperate = UnitGUID, UnitName, UnitCanCooperate;
local UIDropDownMenu_CreateInfo, UIDropDownMenu_AddButton = UIDropDownMenu_CreateInfo, UIDropDownMenu_AddButton;
local frameTypes = {["FRIEND"]=1,["PLAYER"]=1,["PARTY"]=1,["RAID_PLAYER"]=1,["RAID"]=1,["PET"]=false,["SELF"]=false};

function AFriend:OnEnable()
	self:SecureHook("UnitPopup_ShowMenu");
end

function AFriend:UnitPopup_ShowMenu(dropdownMenu, which, unit, name, userData)
	local thisName = name or UnitName(unit);
	which = gsub(which, "PB4_", "");
	if not frameTypes[which] then return; end
	if thisName == UnitName("player") then return; end
	if (UIDROPDOWNMENU_MENU_LEVEL > 1) then return; end
	local info = UIDropDownMenu_CreateInfo();
		info.text=AButtonTxt;
		info.value=AButtons;
		info.owner=which;
		info.func=handlerb;
		info.notCheckable=1;
		info.colorCode=redColor;
		info.arg1 = {["unit"]=unit, ["name"]=thisName};
		info.tooltipTitle=AButtonTxt;
		info.tooltipText=AToolTips;
		UIDropDownMenu_AddButton(info);
end
But I have no idea how to extend this code to LFG menu https://ibb.co/mWStaf
Can someone help me please?

Last edited by Diavol : 10-25-18 at 04:46 PM. Reason: Code
  Reply With Quote