UIDropDownMenu:AddButton()

From Warcraft Wiki
Jump to navigation Jump to search
This function is implemented in :AddButton FrameXML/UIDropDownMenu.lua.

Adds a menu item to the currently open dropdown menu.

UIDropDownMenu_AddButton(info, level)

Arguments

info
Table - a table describing the menu item to add. See the table below for recognized keys.
level
Optional number - nesting level to which the menu item should be added. If 1, the menu item will be added to the outer-most menu level; 2 will add it to the first open sub-menu, 3 to the second open sub-menu, etc.


The info table

Bolded keys are required.

Key Value type Description
text String Button text for this option.
value Any A value tag for this option. Inherits text key if this is undefined.
checked Boolean, Function If true, this button is checked (tick icon displayed next to it)
func Function Function called when this button is clicked. The signature is (self, arg1, arg2, checked)
isTitle Boolean True if this is a title (cannot be clicked, special formatting).
disabled Boolean If true, this button is disabled (cannot be clicked, special formatting)
arg1, arg2 Any Arguments to the custom function assigned in func.
hasArrow Boolean If true, this button has an arrow and opens a nested menu.
icon String A texture path. The icon is scaled down and displayed to the right of the text.
iconOnly Boolean If true, only the icon is shown.
iconXOffset Number Number of pixels to shift the button's icon to the left or right (positive numbers shift right, negative numbers shift left).
iconTooltipTitle String Title of the tooltip shown on icon mouseover
iconTooltipText String Text of the tooltip shown on icon mouseover
iconTooltipBackdropStyle Table Optional Backdrop style of the tooltip shown on icon mouseover
mouseOverIcon Texture An override icon when a button is moused over
tCoord<side> Number SetTexCoord(tCoordLeft, tCoordRight, tCoordTop, tCoordBottom) for the icon. ALL four must be defined for this to work.
tSizeX / tSizeY Number Sets the icon width / height. SetWidth(tSizeX), SetHeight(tSizeY)
iconInfo.tFitDropDownSizeX Boolean Adjusts the dropdowns automatic width by minus 5 (internally used for UIDropDownMenu_AddSeparator to fix the icon adding too much width)
isNotRadio Boolean If true, use a check mark for the tick icon instead of a circular dot.
hasColorSwatch Boolean If true, this button has an attached color selector.
r, g, b Numbers [0.0, 1.0] Initial color value for the color selector.
colorCode String "|cffrrggbb" sequence that is prepended to info.text only if the button is enabled.
swatchFunc Function Function called when the color is changed.
hasOpacity Boolean If true, opacity can be customized in addition to color.
opacity Number [0.0, 1.0] Initial opacity value (0 = transparent).
opacityFunc Function Function called when opacity is changed.
cancelFunc Function Function called when color/opacity alteration is cancelled.
registerForRightClick Boolean Register dropdown buttons for right clicks
notClickable Boolean If true, this button cannot be clicked, but changes the Disabled Font to match the standard white font (GameFontHighlightSmallLeft) - Does not respect fontObject.
noClickSound Boolean Set to 1 to suppress the sound when clicking the button. The sound only plays if .func is set.
notCheckable Boolean If true, this button cannot be checked (selected) - this also moves the button to the left, since there's no space stored for the tick-icon
keepShownOnClick Boolean If true, the menu isn't hidden when this button is clicked.
tooltipTitle String Tooltip title text. The tooltip appears when the player hovers over the button.
tooltipText String Tooltip content text.
tooltipOnButton Boolean Show the tooltip attached to the button instead of as a Newbie tooltip.
tooltipWhileDisabled Boolean Show the tooltip, even when the button is disabled.
tooltipWarning String Warning-style text of the tooltip shown on mouseover
tooltipInstruction String Instruction-style text of the tooltip shown on mouseover
tooltipBackdropStyle Table Optional Backdrop style of the tooltip shown on mouseover
justifyH String Horizontal text justification: "CENTER" for "CENTER", any other value or nil for "LEFT".
fontObject Font Font object used to render the button's text.
owner Frame Dropdown frame that "owns" the current dropdown list.
padding Number Number of pixels to pad the text on the right side.
topPadding Number Extra spacing between buttons
leftPadding Number Number of pixels to pad the button on the left side
midWidth Number Minimum width for this option's line
menuList Table Table used to store nested menu descriptions for the EasyMenu functionality.
customCheckIconAtlas Boolean Needs explanation.
classicChecks Boolean Classic WoW only - needs explanation.
customFrame Frame Allows this button to be a completely custom frame. Custom frame should inherit from UIDropDownCustomMenuEntryTemplate and override appropriate methods

Caveats

  • Button tooltip doesn't work, if it doesn't have tooltipTitle filled.