WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Adding button to the menu (https://www.wowinterface.com/forums/showthread.php?t=56801)

Diavol 10-24-18 01:54 PM

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?

MuffinManKen 10-24-18 06:24 PM

If you post your code it would be a lot easier to help you figure out why it isn't working.

Diavol 10-25-18 12:48 PM

Added to the main post.

myrroddin 10-26-18 12:29 PM

The first two lines should be merged.
Code:

local AFriend = LibStub( blah blah) stuff stuff etc


All times are GMT -6. The time now is 05:38 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI