Dewdrop-2.0
From WowAce Wiki
| Summary | |
|---|---|
| Lib: Dewdrop-2.0 | |
| A library to provide a clean dropdown menu interface. | |
| TOC | 2.4 (20400) |
| Category | Libraries |
| Author | ckknight |
| Details | |
| OptionalDeps | Ace2 |
| Links | |
| Betas | Ace SVN Zip |
| Changelog | FishEye |
Dewdrop-2.0 is a library to provide a clean dropdown menu interface.
Example
local dewdrop = AceLibrary("Dewdrop-2.0")
dewdrop:Open(Minimap,
'children', function()
dewdrop:AddLine(
'text', "Hello, world"
)
end)
API Documentation
:Register(parent, ...)
Registers a given parent with Dewdrop-2.0. Settings are initialized from the other arguments given.
Args
- parent
- Frame - parent frame to register.
- string - don't have a proper frame, instead use a dummy parent
- ...
- Register & Open Arguments
Remarks
This automatically registers the right-click with with the parent frame. Unregistering will cause this not to happen.
Example
dewdrop:Register(Minimap,
'children', function()
dewdrop:AddLine('text', "Text")
end
)
:Unregister(parent)
Unregisters a given parent from Dewdrop-2.0.
Args
- parent
- Frame - registered parent frame.
- string - don't have a proper frame, instead use a dummy parent
Example
dewdrop:Unregister(Minimap)
:Open(parent, ...) or (parent, otherParent) or (parent)
Opens the menu on the given parent, the innards are initialized either with data from Register(parent, ...) or from the given arguments.
Args
- parent
- Frame - parent frame to open.
- string - don't have a proper frame, instead use a dummy parent
- ...
- Register & Open Arguments
- otherParent
- Frame - parent frame to get information on.
Remarks
If you called Register(parent, ...) on the same parent, you do not need to give extra arguments, but if you do, they will take precedent.
Example
dewdrop:Open(Minimap) -- assuming data from the registry
:Close([level])
Closes the given level and sublevels
Args
- level
- number [1, inf) - level to close. (default: 1)
Example
dewdrop:Close(2) -- closes 2nd levels and any sublevels
:Refresh([level])
Refreshes the contents of a given level
Args
- level
- number [1, inf) - level to refresh. (default: 1)
Example
dewdrop:Refresh(2) -- refreshes the second level.
:AddLine(...)
Adds a line to the dropdown menu.
Args
- ...
- A list of key-value pairs to represent information. AddLine Arguments
Remarks
This should only be called inside the init function of Open(frame, func).
Example
dewdrop:AddLine(
'text', "Hello, World!"
)
:AddSeparator([level])
Adds a separator to the dropdown menu. Is a no-op if the menu is empty or the previous line is already a separator.
Args
- level
- Optional. See the "level" AddLine argument. Normally left out.
Remarks
A separator line is simply a disabled line with with the text set to "".
Example
dewdrop:AddSeparator()
:IsOpen(parent)
Returns whether the given parent frame has an open dropdown menu on it.
Args
- parent
- Frame - parent frame to check.
- string - don't have a proper frame, instead use a dummy parent
Returns
boolean - whether the given parent frame has an open dropdown menu.
Example
local open = dewdrop:IsOpen(Minimap)
:GetOpenedParent()
Returns the frame that is the parent of the current open dropdown menu on it, or nil if no menu is open. If the result is treated as a boolean, this could be thought of as ":IsOpen()".
Returns
object - the parent of the current menu or nil if no menu is open
Example
local parent = dewdrop:GetOpenedParent()
:IsRegistered(parent)
Returns whether the given parent frame has been registered with Dewdrop.
Args
- parent
- Frame - parent frame to check.
- string - don't have a proper frame, instead use a dummy parent
Returns
boolean - whether the given parent frame has been registered with Dewdrop.
Example
local registered = dewdrop:IsRegistered(Minimap)
:FeedTable(menutable, [, difference])
Feeds in a generic table to turn into a menu.
Args
- menutable
- table - multi-level table corresponding to a menu using :AddLine() args for keys (use a table keyed 'sub' for the next level if 'hasArrow' is true)
- [difference]
- number - difference to the starting level (default: 0)
Remarks
difference is handy if you want your table to start at level 2 instead of level 1. This occurs within the children of the registration statement.
Returns
boolean - Whether it properly found the position in the table and successfully added lines.
Example
dewdrop:Register("FoodFrame",
'children', function()
dewdrop:FeedTable({
Fruits = {
text = "Yummy Fruits",
func = function() EatAllFruit() end,
hasArrow = true,
subMenu = {
Apple = {
text = "A juicy apple",
func = function() EatApple() end,
},
Strawberry = {
text = "A tasty strawberry",
func = function() EatStrawberry() end,
},
},
},
Vegetables = {
text = "Yucky Vegetables",
func = function() EatYourVegetables() end,
},
})
end
)
:FeedAceOptionsTable(options [, difference])
Feeds in an AceOptions data table to turn into a menu.
Args
- options
- table - AceOptions data table
- [difference]
- number - difference to the starting level (default: 0)
Remarks
difference is handy if you want your AceOptionsTable to start at level 2 instead of level 1. This occurs within the children of the registration statement.
Returns
boolean - Whether it properly found the position in the table and successfully added lines.
Example
dewdrop:Register(Minimap,
'children', function()
dewdrop:FeedAceOptionsTable(options)
end
)
:InjectAceOptionsTable(handler, options)
Inject the default AceOptions data table options of the given handler into the given options table.
Args
- handler
- table - AceOO object from which to draw options.
- options
- table - AceOptions data table, blank or otherwise. type must be "group".
Returns
options
Assorted mixins/classes have their own default options. e.g. AceDB-2.0 has the profile option.
Example
AceLibrary("Dewdrop-2.0"):InjectAceOptionsTable(self, self.myOptions)

