WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Right-click on target menu (https://www.wowinterface.com/forums/showthread.php?t=57644)

Rykkan 10-30-19 12:03 AM

Right-click on target menu
 
I have fixed the BlackList addon to work with WoW Classic. But I cannot get the drop down item when right clicking a player to not be grayed out. Looking for help. It correctly places the menu item under Other Options and names it correctly. But I am not sure why it is grayed out and not usable.

This is the code for the menu:

function BlackList:AddMenuItems()
UnitPopupButtons["AddtoBlacklist"] = { text = "BlackList", dist = 0 }

--Insert it to the end -1
tinsert(UnitPopupMenus["PARTY"], (#UnitPopupMenus["PARTY"])-1, "AddtoBlacklist")
tinsert(UnitPopupMenus["RAID_PLAYER"], (#UnitPopupMenus["RAID_PLAYER"])-1, "AddtoBlacklist")
tinsert(UnitPopupMenus["PLAYER"], (#UnitPopupMenus["PLAYER"])-1, "AddtoBlacklist")
tinsert(UnitPopupMenus["CHAT_ROSTER"], (#UnitPopupMenus["CHAT_ROSTER"])-1, "AddtoBlacklist")
tinsert(UnitPopupMenus["FRIEND"], (#UnitPopupMenus["FRIEND"])-1, "AddtoBlacklist")

hooksecurefunc("UnitPopup_OnClick", function()
if (self.value == "AddtoBlacklist") then
local dropdownMenu = _G["UIDROPDOWNMENU_INIT_MENU"]
if(dropdownMenu.name ~= UnitName("player")) then
BlackList:AddPlayer(dropdownMenu.name)
end
end
end)

end

Rykkan 10-30-19 02:23 PM

I have tried multiple ways to try to fix this, but no matter what I try that selection is always grayed out in the player/target dropdown menu when right-clicking their portrait.

erispope 10-31-19 02:29 AM

How does the code that controls the disabled state for that menu look like?

Is there a function for enabling or disabling each choice that is not present for the blacklist choice?

Rykkan 11-01-19 11:48 AM

Quote:

Originally Posted by erispope (Post 334467)
How does the code that controls the disabled state for that menu look like?

Is there a function for enabling or disabling each choice that is not present for the blacklist choice?

I couldn't find anything, but i found changing it to from PopUpButton to just adding it to the UIDROPDOWNMENU it worked.
local function blackListButton(self)
if self.value == "BlacklistButton" then
-- print("RedButton clicked")
local dropdownMenu = _G["UIDROPDOWNMENU_INIT_MENU"]
if(dropdownMenu.name ~= UnitName("player")) then
BlackList:AddPlayer(dropdownMenu.name)
end
else
print(" WTF how did I fail?")
end
end

hooksecurefunc("UnitPopup_ShowMenu", function()
if (UIDROPDOWNMENU_MENU_LEVEL > 1) then
return
end
local info = UIDropDownMenu_CreateInfo()
info.text = "Add to BlackList"
info.owner = which
info.notCheckable = 1
info.func = blackListButton
info.colorCode = "|cffff0000"
info.value = "BlacklistButton"

UIDropDownMenu_AddButton(info)
end)



All times are GMT -6. The time now is 11:22 AM.

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