Description
Intended for addons with a GUI but only accessible by slash commands, LibAddonButton can be used to create buttons that house menus to display various addons. The button can me moved by dragging it, locked/unlocked by right-clicking it and the menu can be accessed by left-clicking it. New buttons will be automatically unlocked on their first use.
By default, all first level menu items are sorted alphabetically and all sub menu items are displayed in the order they were added.
Registering a button
LibAddonButton.Register("uniqeName", buttonWidth, buttonHeight, "DefaultTexture", "HighlightTexture", "PressedTexture")
By default, if the "PressedTexture" or "HighlightTexture" is left blank, then "DefaultTexture" will be used. If they are all left blank, the default animated gear button will be used.
A texture can be a simple string that is the name of a texture, or an animation. The format of an animation is:
local animation =
{
FPS = 10, -- display 1 frame every 0.1 seconds
Frames = -- this must be an index-based array from 1 to n
{
"FrameTexture1", "FrameTexture2", "FrameTexture3"
}
}
Adding a menu item
LibAddonButton.AddMenuItem("uniqeName", L"label text", callbackFunction)
The callbackFunction will be called when a menu item is clicked.
Adding a cascading menu item
local menu = LibAddonButton.AddCascadingMenuItem("uniqeName", L"label text")
This function returns the created menu that is used to add sub menu items. Examples to add submenu items:
LibAddonButton.AddMenuSubitem(menu, L"A", callbackFunction) menu = LibAddonButton.AddCascadingMenuSubitem(menu, L"B", callbackFunction) LibAddonButton.AddMenuSubitem(menu, L"C", callbackFunction) menu = LibAddonButton.AddCascadingMenuSubitem(menu, L"D", callbackFunction) LibAddonButton.AddMenuSubitem(menu, L"E", callbackFunction)
The above will result in:
A B > C D > E
Overriding the default behavior of the LUp/RUp events
First you must find the button using either method:
local button = LibAddonButton.Register("uniqueName", ... )
local button = LibAddonButton.GetButton("uniqueName")
Then to override the LUp/RUp events:
button:SetLUpOverride(callbackFunction) button:SetRUpOverride(callbackFunction)
Facts
- Date created
- Sep 13, 2010
- Category
- Last update
- Nov 19, 2010
- Development stage
- Release
- Language
- enUS
- License
- GNU General Public License version 3 (GPLv3)
- Curse link
- LibAddonButton
- Downloads
- 5,952
- Recent files