Skip to content
sfmict edited this page Jun 14, 2026 · 37 revisions

LibSFDropDown is designed to be embedded into the addons that use it. The user should never have to worry about what version of the library they have, or even really be aware of the library’s existence.

Embedding the library is a fairly simple task. Simply include LibSFDropDown.xml in your addon’s files and add it into your TOC to be loaded.
Make sure that you include LibStub as well, and that it loaded before LibSFDropDown.

Pulling the library into your addon

local lsfdd = LibStub("LibSFDropDown-1.5")

The library methods

local button = lsfdd:CreateButton([parent[, width]])

Creates a button with DropDownButtonMixin applied.

Arg Type Description
parent frame the parent of the button
width number the width of the button


local button = lsfdd:CreateModernButton([parent[, width]])

Creates a button with DropDownButtonMixin applied.

Arg Type Description
parent frame the parent of the button
width number the width of the button


local button = lsfdd:CreateStretchButton([parent[, width[, height[, wrap]]]])

Creates a stretch button with DropDownButtonMixin applied.

Arg Type Description
parent frame the parent of the button
width number the width of the button
height number the height of the button
wrap boolean 'true' to wrap text


lsfdd:SetMixin(frame)

Applies DropDownButtonMixin to the frame and returns the same frame.

Arg Type Description
frame frame, table the frame to which DropDownButtonMixin will be applied


lsfdd:IterateCreatedButtons()

Iterates the created buttons.

lsfdd:IterateCreatedModernButtons()

Iterates the created modern buttons.

lsfdd:IterateCreatedStretchButtons()

Iterates the created stretchable buttons.

lsfdd:GetMenu([level])

Returns the menu of the specified level.

Arg Type Description
level number menu level


lsfdd:IterateMenus()

Iterates the menus.

lsfdd:IterateMenuButtons([level])

Iterates the buttons of the specified menu level.

Arg Type Description
level number menu level


lsfdd:IterateSearchFrames()

Iterates the search frames.

lsfdd:IterateSearchFrameButtons([num])

Iterates the buttons of the specified search frame.

Arg Type Description
num number number of search frame


lsfdd:CreateMenuStyle(name[, overwrite], frameFunc)

Creates the menu style. Returns true if the style is created.

Arg Type Description
name string style name
overwrite boolean rewrite if the style with the same name exists
frameFunc function(menuFrame) the function that returns a style frame


lsfdd:SetDefaultStyle(name)

Sets the default menu style.

Arg Type Description
name string style name


lsfdd:SetMenuStyle(name)

Sets style with name "menu".

Arg Type Description
name string style name

DropDownButtonMixin methods

button:ddSetSelectedValue(value, [level[, anchorFrame]])

Only for the button that was created by lsfdd:CreateButton().
Sets value for the button.

Arg Type Description
value optional the value that will be compared with the value on the menu item
level number menu level
anchorFrame frame or "cursor" anchor frame for the menu


button:ddGetSelectedValue()

Returns the value of the button.

button:ddSetSelectedText(text[, icon[, iconInfo[, iconOnly[, fontObject[, font]]]]])

Only for the button that was created by lsfdd:CreateButton().
Sets the text and icon for the button.

Arg Type Description
text string text that's set to the button
icon string, number path to icon or iconID or atlas
iconInfo table icon info table
iconOnly boolean stretches the texture to the width of the button
fontObject fontObject the font object for button text
font font the font for button text


button:ddSetAutoSetText(enabled)

Only for the button that was created by lsfdd:CreateButton().
Sets to automatically set the text for the button from the selected menu item (Default: true).

Arg Type Description
enabled boolean true to automatically set the text


button:ddInitialize([level[, value]], initFunction)

Only for the button that was created by lsfdd:CreateButton().
Sets the initialization function and initializes to set the button text.

Arg Type Description
level number menu level
value optional the value that will be passed to the function initFunction
initFunction function a function that adds buttons to the menu function(self, level, value)
self - button frame
level - menu level
value - the value that was passed to ddInitialize or ddToggle


button:ddSetInitFunc(initFunction)

Sets the initialization function.

Arg Type Description
initFunction function a function that adds buttons to the menu function(self, level, value)
self - button frame
level - menu level
value - the value that was passed to ddToggle


button:ddSetDisplayMode(displayMode)

Sets the style for the menu.

Arg Type Description
displayMode string nil, "menu" or "customStyle" for sets the stlyle of the menu


button:ddSetNoGlobalMouseEvent(enabled[, frame])

Sets a flag for a frame or self that disables closing the menu when you click on it.

Arg Type Description
enabled boolean 'true' to disable closing the menu
frame frame any frame


button:ddHideWhenButtonHidden([frame])

Hooks the OnHide event from the frame or self to close the menu.

Arg Type Description
frame frame any frame


button:ddSetMenuButtonHeight(height)

Sets the height of the menu button

Arg Type Description
height number menu button height (default 20)


button:ddSetMaxHeight(height)

Sets the maximum height of the menu if the menu is higher then scrolling is added.

Arg Type Description
height number maximum menu height


button:ddSetMinMenuWidth(width)

Sets the minimum width of the menu.

Arg Type Description
width number minimum menu height


button:ddSetOpenMenuUp(enabled)

Sets the menu opening direction.

Arg Type Description
enabled boolean if true the menu opens up


button:ddIsOpenMenuUp()

Return true if the menu opens up.

button:ddSetValue(value)

Sets the value that will be passed to the initFunction function if the value passed in ddToggle is nill.

Arg Type Description
height any any value


button:ddToggle(level, value, anchorFrame[, point][, rPoint][, xOffset[, yOffset]])

Openes / closes the menu.

Arg Type Description
level number menu level
value optional the value that will be passed to the function initFunction
anchorFrame frame or "cursor" anchor frame for the menu
point string point of frame
rPoint string point of relative frame
xOffset number x-offset from anchorFrame
yOffset number y-offset form anchorFrame


button:ddRefresh([level[, anchorFrame]])

Refreshes the menu items.

Arg Type Description
level number menu level
anchorFrame frame or "cursor" anchor frame for the menu


button:ddIsMenuShown([level])

Returns true if the menu is open for that button.

Arg Type Description
level number menu level


button:ddCloseMenus([level])

Closes the menu.

Arg Type Description
level number menu level


button:ddAddSeparator([level])

Adds a separator to the menu.

Arg Type Description
level number menu level


button:ddGetSeparatorInfo()

Returns separator info table.

button:ddAddSpace([level])

Adds an empty line to the menu.

Arg Type Description
level number menu level


button:ddGetSpaceInfo([level])

Returns space info table.

button:ddAddButton(info[, level])

Adds a button to the menu.

Arg Type Description
info table info table
level number menu level


button:ddEasyMenu(menuList, anchorFrame[, xOffset, yOffset[, displayMode]])

Sets and opens the menu from the menuList table.

Arg Type Description
menuList table menuList table
anchorFrame frame or "cursor" anchor frame for the menu
xOffset number x-offset from anchorFrame
yOffset number y-offset from anchorFrame
displayMode string nil, menu or customStyle for sets the stlyle of the menu

Icon info table

It's a table with arguments:

Arg Value Description
tCoordLeft [0.0 - 1.0] left for SetTexCoord func
tCoordRight [0.0 - 1.0] right for SetTexCoord func
tCoordTop [0.0 - 1.0] top for SetTexCoord func
tCoordBottom [0.0 - 1.0] bottom for SetTexCoord func
tSizeX [number] icon width
tSizeY [number] icon height
tWrap [nil, string] horizontal wrapping type from SetTexture function
r [0.0 - 1.0] -- r for SetVertexColor func
g [0.0 - 1.0] -- g for SetVertexColor func
b [0.0 - 1.0] -- b for SetVertexColor func
a [0.0 - 1.0] -- a for SetVertexColor func

Info table

It's a table with arguments:

Arg Value Description
text [string, function(self, arg1, arg2)] the text of the button or function that returns the text
value [optional] the value that is set to button.value
func [function(self, arg1, arg2, checked)] the function that is called when you click the button
checked [nil, true, function(self, arg1, arg2)] check the button if true or function returns true
isNotRadio [nil, true] check the button uses radial image if false check box image if true
notCheckable [nil, true] shrink the size of the buttons and don't display a check box
isTitle [nil, true] if it's a title the button is disabled and the font color is set to yellow
disabled [nil, true, function(self, arg1, arg2)] disable the button and show an invisible button that still traps the mouseover event so menu doesn't time out
hasArrow [nil, true] show the expand arrow for multilevel menus
hasArrowUp [nil, true] the same as hasArrow but opens the menu up
keepShownOnClick [nil, true] don't hide the dropdownlist after a button is clicked
arg1 [optional] this is the first argument used by info.func
arg2 [optional] this is the second argument used by info.func
icon [texture] an icon or an atlas for the button
iconOnly [nil, true] stretches the texture to the width of the button
iconInfo [table] icon info table
indent [number] number of pixels to pad the button on the left side
remove [function(self, arg1, arg2)] the function that is called when you click the remove button
removeDoNotHide [nil, true] don't hide menu when clicking remove button
order [function(self, delta, arg1, arg2)] the function that is called when you click the up or down arrow button
hasColorSwatch [nil, true] show color swatch or not, for color selection
r [0.0 - 1.0] red color value of the color swatch
g [0.0 - 1.0] green color value of the color swatch
b [0.0 - 1.0] blue color value of the color swatch
swatchFunc [function] function called by the color picker on color change
hasOpacity [nil, ture] show the opacity slider on the colorpicker frame
opacity [0.0 - 1.0] percentatge of the opacity, 1.0 is fully shown, 0 is transparent
opacityFunc [function] function called by the opacity slider when you change its value
cancelFunc [function(previousValues)] function called by the colorpicker when you click the cancel button (it takes the previous values as its argument)
justifyH [nil, "CENTER", "RIGHT"] justify button text
fontObject [fontObject] the font object replacement for Normal and Highlight
rightFontObject [fontObject] the font object replacement for info.rightText
font [font] the font replacement for Normal and HighLight
rightFont [font] the font replacement for info.rightText
OnEnter [function(self, arg1, arg2)] handler OnEnter
OnLeave [function(self, arg1, arg2)] handler OnLeave
tooltipWhileDisabled [nil, true] show the tooltip, even when the button is disabled
OnTooltipShow [function(self, tooltipFrame, arg1, arg2)] handler tooltip show
--- --- ---
widgets [table] A table of widgets, that adds mini buttons to the button, looks like
{
{
width = [nil, number], -- width of widget, default 16
height = [nil, number], -- height of widget, default 16
icon = [texture], -- An icon or an atlas for the widget
iconInfo = [nil, table], -- icon info table
OnClick = [function(infoBtn, arg1, arg2)] -- The function that is called when you click the button
OnEnter = [function(infoBtn, arg1, arg2)] -- Handler OnEnter
OnLeave = [function(infoBtn, arg1, arg2)] -- Handler OnLeave
OnTooltipShow = [function(infoBtn, tooltipFrame, arg1, arg2)] -- Handler tooltip show
},
}
--- --- ---
customFrame [frame] Allows this button to be a completely custom frame
fixedWidth [nil, true] If nil then custom frame is stretched
OnLoad [function(customFrame)] Function called when the custom frame is attached
--- --- ---
search [function(searchString, infoText, infoRightText, btnInfo, highlightColorCode, defaultFunc)] Optional custom search function, must return true/false, textHighlighted/nil, rightTextHighlighted/nil
highlightColor [nil, hex color] A color for highlighted found text, default ffd200
hideSearch [nil, true] Remove SearchBox if info.list displays as scroll menu
autoFocus [nil, true] Auto focus SearchBox if it's visible
listMaxSize [nil, number] Number of max size info.list, after a scroll frame is added, default 20
searchAlways [nil, true] Always displays search, regardless of list size
list [table] the table of info buttons, if there are more than 20 buttons, a scroll frame is added

Clone this wiki locally