Monday, 12 August 2024
Friday, 27 January 2023
Saturday, 9 July 2022
Monday, 31 May 2021
Saturday, 16 January 2021
Sunday, 4 October 2020
Friday, 13 December 2019
Thursday, 12 December 2019
Friday, 21 September 2018
Tuesday, 27 March 2018
Monday, 30 January 2017
Friday, 27 January 2017
Friday, 23 December 2016
WoW - Add Button to Target Dropdown Menu
I was having a real issue trying to add buttons to the target right click dropdown menu in WoW.
After posting on a few questions on the CurseForge, WoW Interface and WoW UI & Macro forums without much success, I pulled apart the AddFriend addon and created the following chunk.
local function testDropdownMenuButton(self)
if self.value == "GreenButton" then
print("GreenButton clicked")
elseif self.value == "RedButton" then
print("RedButton clicked")
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 = "Dropdown Menu Button"
info.owner = which
info.notCheckable = 1
info.func = testDropdownMenuButton
if UnitName("target")=="Tauren Commoner" or UnitName("target")=="Orgrimmar Brave" then
info.colorCode = "|cff00ff00"
info.value = "GreenButton"
else
info.colorCode = "|cffff0000"
info.value = "RedButton"
end
UIDropDownMenu_AddButton(info)
end)
This is the most economical solution that I could work out, (proper coders could probably reduce the code further but this did work for me).
I also decided to have the button click to run a separate function for the sake of clarity.
I hope that this can provide benefit to other beginners.
After posting on a few questions on the CurseForge, WoW Interface and WoW UI & Macro forums without much success, I pulled apart the AddFriend addon and created the following chunk.
local function testDropdownMenuButton(self)
if self.value == "GreenButton" then
print("GreenButton clicked")
elseif self.value == "RedButton" then
print("RedButton clicked")
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 = "Dropdown Menu Button"
info.owner = which
info.notCheckable = 1
info.func = testDropdownMenuButton
if UnitName("target")=="Tauren Commoner" or UnitName("target")=="Orgrimmar Brave" then
info.colorCode = "|cff00ff00"
info.value = "GreenButton"
else
info.colorCode = "|cffff0000"
info.value = "RedButton"
end
UIDropDownMenu_AddButton(info)
end)
This is the most economical solution that I could work out, (proper coders could probably reduce the code further but this did work for me).
I also decided to have the button click to run a separate function for the sake of clarity.
I hope that this can provide benefit to other beginners.
Thursday, 17 November 2016
Thursday, 3 November 2016
Thursday, 29 September 2016
Subscribe to:
Posts (Atom)















