Skip to content
Phanx edited this page Nov 26, 2014 · 1 revision

PhanxConfig-Dropdown

Simple dropdown menu widget generator for GUI configuration. Requires LibStub.

Usage:

lib = LibStub("PhanxConfig-Dropdown")

Library Methods:

Create a dropdown menu widget:

dropdown = lib:New(parentFrame, labelText[, tooltipText][, menuList][, keepShownOnClick])

Arguments:

  1. parentFrame - frame reference
  2. labelText - string; text to be displayed on the color picker
  3. tooltipText - string; text to be be displayed in a tooltip when moving the cursor over the color picker (optional)
  4. menuList - table; a list of items to be shown in the dropdown menu (optional, may be set later)
  5. keepShownOnClick - boolean: whether the menu should remain open when a menu item is clicked (optional, default is false)

Alternate syntax for embedding:

dropdown = lib.CreateDropdown(parentFrame, labelText[, tooltipText][, menuList][, keepShownOnClick])

Widget Callbacks:

Set a function to be run when a menu item is clicked:

dropdown.OnValueChanged = function(dropdown, value, text) ... end

Set a function to be run when a menu item is displayed:

dropdown.OnListButtonChanged = function(dropdown, button, item, selected) ... end

This may be used to, for example, display a list of available fonts with each item shown in the appropriate font.

Set a function to be run when the menu is requested, before it is displayed:

dropdown.PreUpdate = function(dropdown) ... end

Generally you would use this to update a dynamic list of values.

Widget Methods:

Set the list of items to be displayed by the menu:

dropdown:SetList(list)

The list should be an indexed table of either simple string values, or table values containing EasyMenu-compatible key/value pairs. Currently only the text, value, selected, and disabled properties are supported.

Get the current list of items displayed by the menu:

list = dropdown:GetList()

Set whether the menu should remain open when a value is clicked:

dropdown:SetKeepShownOnClick(state)

License

Copyright © 2009–2014 Phanx. All rights reserved. You MAY distribute this library WITHOUT CHANGES inside addons that make use of it. You MAY NOT distribute this library by itself or with changes. You MAY use any or all of the source code from this library in your own library or addon, as long as you do not use the name of this library or the name of its author anywhere in your work outside of an optional attribution. See the comment header in the library file for more details.