AddDropDownMenuButton

'This function has been found to be faulty. It taints the pathway of other buttons in all drop downs, whereby the built-in security system prevent some secure functions from running. Do not use this function.'

Calls to this function add additional buttons/links to the drop down/ right click popup menus within World of Warcraft.

&lt;PREFIX&gt;_addDropDownMenuButton(uid, dropdown, index, title, usable, onClick[, hint])

Arguments

 * uid: String - A unique id to identify your custom button.
 * dropdown: String - The string represending the drop down menu to add this button too.
 * index: Integer - An integer saying where you would like it placed in the list.
 * title: String - The text to display on the button.
 * usable: Function - A function that returns true if the current setup is valid for it to display. (Two parameter: target name, target unit|Returns Boolean)
 * onClick: Function - A function that is performed when the button is clicked. (Four parameters: the button itself, target name, target unit, target server|No return)

Note:
 * The parameters target name, target unit and target server for the usable and onClick functions are not garunteed to be filled, and thus may have values of 'nil'.

Additional
Here is the list of WoW predefined drop downs and their button lists:

Example
&lt;PREFIX&gt;_addDropDownMenuButton("HELLOW_WORLD","SELF",3,"Hello",function(name,unit) return true; end;,function(self,name,unit,server) &lt;PREFIX&gt;_printMSG("Hello World!"); end,"Click to greet the world");

Result
This example will add a new button called "Hello" to the drop down/popup when you right click you icon in the top left. Clicking on it will write "Hello World!" to the default chat frame.

Code
Note:
 * This code uses the support function allAreType

function _addDropDownMenuButton(uid, dropdown, index, title, usable, onClick, hint) if(not (_allAreType('string',uid,dropdown,title) and _allAreType('function',usable,onClick) and type(index)=="number" and (hint==nil or type(hint)=="string") ) ) then return; end if(not UnitPopupMenus[dropdown]) then return; end tinsert(UnitPopupMenus[dropdown],index,uid); if(hint) then UnitPopupButtons[uid] = { text = title, dist = 0, tooltip = hint}; else UnitPopupButtons[uid] = { text = title, dist = 0}; end USER_DROPDOWNBUTTONS[uid] = {func = function(self) onClick(self,UIDROPDOWNMENU_OPEN_MENU.name,UIDROPDOWNMENU_OPEN_MENU.unit,UIDROPDOWNMENU_OPEN_MENU.server); end, enabled = usable}; end

USER_DROPDOWNBUTTONS = {};

local default_UIDropDownMenu_AddButton = UIDropDownMenu_AddButton; UIDropDownMenu_AddButton = function(info, level) if(USER_DROPDOWNBUTTONS[info.value]) then local dropdownFrame = getglobal(UIDROPDOWNMENU_INIT_MENU); if(not USER_DROPDOWNBUTTONS[info.value].enabled(UIDROPDOWNMENU_OPEN_MENU.name,UIDROPDOWNMENU_OPEN_MENU.unit) ) then return end info.func = USER_DROPDOWNBUTTONS[info.value].func; end; default_UIDropDownMenu_AddButton(info,level); end;