Skip to content
This repository has been archived by the owner on Jul 7, 2024. It is now read-only.
CI edited this page May 10, 2024 · 9 revisions

Documentation for the Menu object. Created with LibDropDown:NewMenu().


Menu:Refresh()

See Menu:Toggle().


Menu:Toggle()

Toggles the dropdown menu, closing all others (see LibDropDown:CloseAll()).


Menu:UpdateLine(index, data)

Update a line with the given index with the supplied data.


Menu:AddLines(...)

See Menu:AddLine(data), this one does the exact same thing, except
this one can add more than one line at a time.

  • ...: One or more tables containing line information.

Menu:AddLine(data)

Adds a line using the given data to the menu menu.
Everything™ is optional, some are exclusive with others.

  • data:
  • text: Text to show on the line (string)
  • isTitle: Turns the text into a title (boolean)
  • isSpacer: Turns the line into a spacer (boolean)
  • func: Function to execute when clicking the line (function)
    Arguments passed: button, args (unpacked).
  • keepShown: Keeps the dropdown shown after clicking the line (boolean)
  • args: Table of arguments to pass through to the click function (table)
  • tooltip: Tooltip contents (string)
  • tooltipTitle: Tooltip title (string)
  • tooltipWhileDisabled: Enable tooltips while disabled (boolean)
  • checked: Show or hide a checkbox (boolean/function)
  • isRadio: Turns the checkbox into a radio button (boolean)
  • isColorPicker: Adds a color picker to the line (boolean)
  • colorR: Red color channel, 0-1 (number)
  • colorG: Green color channel, 0-1 (number)
  • colorB: Blue color channel, 0-1 (number)
  • colorOpacity: Alpha channel, 0-1 (number)
  • colorPickerCallback: Callback function for the color picker (function)
    Arguments passed: color, see SharedXML\Util.lua's ColorMixin.
  • icon: Texture path for the icon to embed into the start of text (string)
  • iconTexCoords: Texture coordinates for cropping the icon (array)
  • iconWidth: Width of the displayed icon (number)
  • iconHeight: Height of the displayed icon (number)
  • iconFileWidth: File width of the icon (number)
  • iconFileHeight: File height of the icon (number)
  • atlas: Atlas to embed into the start of text (string)
  • atlasWidth: Width of the displayed atlas (number)
  • atlasHeight: Height of the displayed atlas (number)
  • atlasOffsetX: Horizontal offset for atlas (number)
  • atlasOffsetY: Vertical offset for atlas (number)
  • atlasOffset: Common offset for both axis for atlas (number)
  • disabled: Disables the whole line (boolean)
  • texture: Sets background texture that spans the line (string)
  • textureColor: Sets the color of the background texture (ColorMixin object)
  • font: Font to use for the line (string)
  • fontSize: Font size to use for the line, requires font to be set (number)
  • fontFlags: Font flags to use for the line, requires font to be set (string)
  • fontObject: Font object to use for the line (string/FontInstance)
  • menu: Sub-menu for the current menu line (array)
    This needs to contain one or more tables of data (all of the above) in an
    indexed array. Can be chained.

Notes

The following are exclusive options, only one can be used at a time:

  • isSpacer
  • isTitle
  • menu
  • isColorPicker
  • checked
  • font
  • fontObject

Menu:RemoveLine(index)

Removes a specific line by index.


Menu:ClearLines()

Removes all lines in the menu.


Menu:NumLines()

Returns the number of lines in the menu.


Menu:Refresh()

Iterates through every line and refreshes it with the latest data.

If used to refresh the checked state of a line, make sure to set the lines' data.checked to a function that will return the current state.


Menu:SetStyle(name)

Sets the active style for all menus related to this one.


Menu:GetStyle()

Returns the name of the active style for the menu (and child menus).


Menu:SetAnchor(point, anchor, relativePoint, x, y)

Replaces the default anchor with a custom one. Exact same parameters as in Widgets:SetPoint, read that documentation instead.


Menu:GetAnchor()

Returns the point data for the registered anchor (see Widgets:GetPoint).


Menu:SetAnchorCursor(state)

Allows the anchor to be overridden and places the menu on the cursor.

  • state: Enables/disables cursor anchoring (boolean)

Menu:IsAnchorCursor()

Returns the boolean state of whether the menu should be anchored to the cursor or not.


Menu:SetCheckAlignment(alignment)

Sets the alignment of check/radio buttons within the menu.

  • alignment: Either "LEFT" or "RIGHT" (default) (string)