Thread Tools Display Modes
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
10-24-18, 06:24 PM   #2
MuffinManKen
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 106
If you post your code it would be a lot easier to help you figure out why it isn't working.
  Reply With Quote
10-25-18, 12:48 PM   #3
Diavol
A Defias Bandit
Join Date: Jul 2012
Posts: 2
Added to the main post.
  Reply With Quote
10-26-18, 12:29 PM   #4
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
The first two lines should be merged.
Code:
local AFriend = LibStub( blah blah) stuff stuff etc
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Adding button to the menu

Thread Tools
Display Modes

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