- Embed Methods:
-
DewdropLib:GetInstance("version")
- Library Functions:
-
Register(parent, ...)
Unregister(parent)
Open(parent, ...)
Close([level])
Refresh([level])
AddLine(...)
IsOpen(parent)
IsRegistered(parent)
- Register/Open arguments;
-
children
point
relativePoint
cursorX
cursorY
dontHook Register only
- AddLine arguments:
-
text
level
disabled
isTitle
notClickable
textR, textG, textB
notCheckable
isRadio
checked
checkIcon
func
arg1, arg2, arg3
hasColorSwatch
r, g, b
swatchFunc
hasOpacity
opacityFunc
opacity
cancelFunc
hasArrow
value
hasSlider
sliderTop
sliderBottom
sliderFunc
sliderValue
textHeight
justifyH
tooltipTitle
tooltipText
closeWhenClicked
- Embed Methods:
-
- DewdropLib:GetInstance("version")
-
- Returns an instance of DewdropLib with the specified version. If the version cannot be found, an error occurs.
- Arguments:
-
- ("version")
- "version":
- String - the major version of the library, currently "1.0"
- Returns:
- An instance of DewdropLib with the specified version
- Example:
- local dewdrop = DewdropLib:GetInstance("1.0")
- Library Functions:
-
- Register(parent, ...)
-
- Registers a given parent with DewdropLib. Settings are initialized from the other arguments given.
-
- Arguments:
-
- (parent, ...)
- parent:
- Frame - parent frame to register.
- ...
- Register/Open arguments
- Returns:
-
nil
- 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 TabletLib.
-
- Arguments:
-
- (parent)
- parent:
- Frame - registered parent frame.
- Returns:
-
nil
- Example:
- tablet:Unregister(Minimap)
- Open(parent, ... or parent, otherParent)
-
- Opens the menu on the given parent, the innards are initialized either with data from Register(parent, ...) or from the given arguments.
-
- Arguments:
-
- (parent, ...) or (parent, otherParent)
- parent:
- Frame - parent frame to open.
- ...
- Register/Open arguments
- otherParent:
- Frame - parent frame to get information on.
- Returns:
-
nil
- 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.
-
- Arguments:
-
- ([level])
- level:
- Integer - Number of the level [1, inf). Assume 1 if not given.
- Returns:
-
nil
- Example:
- dewdrop:Close(2) -- closes 2nd levels and any sublevels
- Refresh([level])
-
- Refreshes the contents of a given level
-
- Arguments:
-
- ([level])
- level:
- Integer - Number of the level [1, inf). Assume 1 if not given.
- Returns:
-
nil
- Example:
- dewdrop:Refresh(1) -- refreshes the first level.
- AddLine(...)
-
- Adds a line to the dropdown menu.
-
- Arguments:
-
- (...)
- A list of key-value pairs to represent information.
- Returns:
-
nil
- Remarks:
-
This should only be called inside the init function of Open(frame, func).
- Example:
- dewdrop:AddLine(
'text', "Hello, World!"
)
- IsOpen(parent)
-
- Returns whether the given parent frame has an open dropdown menu on it.
- Arguments:
-
- (parent)
- parent:
- Frame - parent frame to check.
- Returns:
-
Boolean - whether the given parent frame has an open dropdown menu.
- Example:
- local open = dewdrop:IsOpen(Minimap)
- IsRegistered(parent)
-
- Returns whether the given parent frame has been registered with Dewdrop.
- Arguments:
-
- (parent)
- parent:
- Frame - parent frame to check.
- Returns:
-
Boolean - whether the given parent frame has been registered with Dewdrop.
- Example:
- local registered = dewdrop:IsRegistered(Minimap)
- Register/Open arguments;
-
- children
-
- function(level, value, valueN_1, valueN_2, valueN_3, valueN_4) - function to describe the innards of the menu.
-
- Remarks:
-
-
value is the value of the menu just opened, where the level number is N.
valueN_1 is the value of level N-1, and so forth onto valueN_4, which is the value of level N-4.
- Example:
- dewdrop:Register(Minimap,
'children', function(level, value)
dewdrop:AddLine('text', "Text")
end
)
- point
-
- String - the main attach point of the menu.
- Function - a function which returns the main attach point of the menu and, optionally, the relative attach point.
- Example:
- dewdrop:Register(Minimap,
'point', function(parent)
return "TOPRIGHT", "TOPLEFT"
end
)
- relativePoint
-
- String - the relative attach point of the menu.
- Function - a function which returns the relative attach point of the menu.
- Example:
- dewdrop:Register(Minimap,
'point', function(parent)
return "TOPRIGHT"
end,
'relativePoint', function(parent)
return "TOPLEFT"
end
)
- cursorX
-
- Boolean - Whether the menu follows the cursor on the x-axis
- Remarks:
- In this case, point should be "BOTTOM" or "TOP", and relativePoint should be the opposite.
- Example:
- dewdrop:Register(Minimap,
'point', "TOP",
'relativePoint', "BOTTOM",
'cursorX', true
)
- cursorY
-
- Boolean - Whether the menu follows the cursor on the y-axis
- Remarks:
- In this case, point should be "LEFT" or "RIGHT", and relativePoint should be the opposite.
- Example:
- dewdrop:Register(Minimap,
'point', "LEFT",
'relativePoint', "RIGHT",
'cursorY', true
)
- dontHook Register only
-
- Boolean - whether the mouse click scripts will be hooked to open/close the menu. You will need to manually call Open() if you do this.
- Example:
- dewdrop:Register(Minimap,
'point', "LEFT",
'dontHook', true
)
- AddLine arguments:
-
- text
-
- String - the text on the button.
-
- Example:
- dewdrop:AddLine(
'text', "Hello, World!",
)
- level
-
- Integer - the level the line should be added at.
-
- Remarks:
-
In most cases, you won't need this, as the level is inferred automatically.
- Example:
- dewdrop:AddLine(
'text', "Hello, World!",
'level', 2
)
- disabled
-
- Boolean - whether the button is disabled.
-
- Remarks:
-
Disabling causes the button to be unclickable and makes the text gray.
- Example:
- dewdrop:AddLine(
'text', "Hello, World!",
'disabled', true
)
- isTitle
-
- Boolean - whether the button is a title.
-
- Remarks:
-
Being a title causes the button to be disabled, but have the standard yellow color.
- Example:
- dewdrop:AddLine(
'text', "I am a title",
'isTitle', true
)
- notClickable
-
- Boolean - whether the button is clickable or not.
-
- Remarks:
-
Being unclickable causes the button to be disabled, but have the standard white color, so it would look like other buttons.
- Example:
- dewdrop:AddLine(
'text', "Hello, world!",
'notClickable', true
)
- textR, textG, textB
-
- textR
- Number - The red value. [0, 1]
- textG
- Number - The green value. [0, 1]
- textB
- Number - The blue value. [0, 1]
- Remarks:
-
Sets the text color of the button, overriding disabled, isTitle, or notClickable's colors.
This only works if all three colors are set.
- Example:
- dewdrop:AddLine(
'text', "Hello, world!",
'textR', 1,
'textG', 1,
'textB', 1
)
- notCheckable
-
- Boolean - whether the button is checkable or not.
-
- Remarks:
-
Really, this being set just causes the blank space that would be normally for a checkbox to not be there.
- Example:
- dewdrop:AddLine(
'text', "Hello, world!",
'notCheckable', true
)
- isRadio
-
- Boolean - whether the button is a radio button.
-
- Remarks:
-
If set to true, it uses a texture similar to "Interface\Buttons\UI-RadioButton", which is 4 buttons side-by-side, unchecked, checked, highlight, and blank.
- Example:
- dewdrop:AddLine(
'text', "Hello, world!",
'isRadio', true,
)
- checked
-
- Boolean - whether the button is checked or not.
-
- Remarks:
-
If set to true, it sets the check's alpha to fully visible, otherwise makes it invisible.
- Example:
- dewdrop:AddLine(
'text', "Hello, world!",
'checked', math.random() < 0.5
)
- checkIcon
-
- String - path to the check texture.
-
- Remarks:
-
If not set, assume "Interface\\Buttons\\UI-CheckBox-Check"
- Example:
- dewdrop:AddLine(
'text', "Hello, world!",
'checkIcon', "Interface\\Buttons\\UI-CheckBox-Check"
)
- func
-
- function(arg1, arg2, arg3) - function to call when button is clicked.
-
- Remarks:
-
The args fed in are the ones given by arg1, arg2, and arg3.
After being called, the menu level is refreshed, so any checks or whatnot are updated.
- Example:
- dewdrop:AddLine(
'text', "Hello, world!",
'func', function()
print("Click!")
end
)
- arg1, arg2, arg3
-
- arg1
- Value - First value fed into the given func
- arg2
- Value - Second value fed into the given func
- arg3
- Value - Third value fed into the given func
- Remarks:
-
You don't need all 3 to work, you may only specify if needed.
- Example:
- dewdrop:AddLine(
'text', "Hello, world!",
'func', function(val)
print("Click! " .. val)
end,
'arg1', math.random()
)
- hasColorSwatch
-
- Boolean - whether the button has a color swatch.
-
- Remarks:
-
If hasColorSwatch is true, then func has no purpose, since clicking opens up a color picker.
- Example:
- dewdrop:AddLine(
'text', "Hello, world!",
'hasColorSwatch', true
)
- r, g, b
-
- r
- Number - The red value. [0, 1]
- g
- Number - The green value. [0, 1]
- b
- Number - The blue value. [0, 1]
- Remarks:
-
Sets the color of the color swatch, and conseqently, the color picker.
This only works if all three colors are set.
- Example:
- dewdrop:AddLine(
'text', "Hello, world!",
'hasColorSwatch', true,
'r', 1,
'g', 1,
'b', 1
)
- swatchFunc
-
- function(r, g, b) - function called when the color changes.
- Remarks:
-
Requires that hasColorSwatch is true.
- Example:
- dewdrop:AddLine(
'text', "Hello, world!",
'hasColorSwatch', true,
'swatchFunc', function(r, g, b)
print("New color: " .. r .. "-" .. g .. "-" .. b)
end
)
- hasOpacity
-
- Boolean - whether the color picker includes opacity.
- Remarks:
-
Requires that hasColorSwatch is true.
- Example:
- dewdrop:AddLine(
'text', "Hello, world!",
'hasColorSwatch', true,
'hasOpacity', true
)
- opacityFunc
-
- function(value) - function called when the opacity changes.
- Remarks:
-
Requires that hasColorSwatch and hasOpacity are true.
- Example:
- dewdrop:AddLine(
'text', "Hello, world!",
'hasColorSwatch', true,
'hasOpacity', true
'opacityFunc', function(value)
print("New alpha: " .. value)
end
)
- opacity
-
- Number - current opacity level. [0, 1]
- Remarks:
-
Requires that hasColorSwatch and hasOpacity are true.
- Example:
- dewdrop:AddLine(
'text', "Hello, world!",
'hasColorSwatch', true,
'hasOpacity', true
'opacity', math.random()
)
- cancelFunc
-
- function(r, g, b, a) - function called when cancel is pushed. Arguments are the previous values.
- Remarks:
-
Requires that hasColorSwatch and hasOpacity are true.
- Example:
- dewdrop:AddLine(
'text', "Hello, world!",
'hasColorSwatch', true,
'hasOpacity', true
'r', 0,
'g', 0.5,
'b', 1,
'opacity', 1
'cancelFunc', function(r, g, b, a)
assert(r == 0 and g == 0.5 and b == 1 and a == 1)
end
)
- hasArrow
-
- Boolean - whether button has an arrow.
- Remarks:
-
Requires that either value is not nil or hasSlider is true.
- Example:
- dewdrop:AddLine(
'text', "Hello, world!",
'hasArrow', true,
'value', "hello"
)
- value
-
- Value - any unique, identifiable value.
- Remarks:
-
Requires that hasArrow is true.
The same value will be fed in to the initalizer function when the sublevel is opened.
- Example:
- if level == 1 then
dewdrop:AddLine(
'text', "Hello,",
'hasArrow', true,
'value', "hello"
)
elseif level == 2
if value == "hello" then
dewdrop:AddLine(
'text', "World!"
)
end
end
- hasSlider
-
- Boolean - whether the sublevel is a slider.
- Remarks:
-
Requires that hasArrow is true.
- Example:
- dewdrop:AddLine(
'text', "Hello, world!",
'hasArrow', true,
'hasSlider', true
)
- sliderTop
-
- String - the text representing the high value
- Remarks:
-
Requires that hasArrow and hasSlider are true.
If not given, "100%" is assumed.
- Example:
- dewdrop:AddLine(
'text', "Hello, world!",
'hasArrow', true,
'hasSlider', true
'sliderTop', '100%'
)
- sliderBottom
-
- String - the text representing the high value
- Remarks:
-
Requires that hasArrow and hasSlider are true.
If not given, "0%" is assumed.
- Example:
- dewdrop:AddLine(
'text', "Hello, world!",
'hasArrow', true,
'hasSlider', true
'sliderBottom', '0%'
)
- sliderValue
-
- Number - the current value of the slider. [0, 1]
- Remarks:
-
Requires that hasArrow and hasSlider are true.
If not given, 0.5 is assumed.
- Example:
- dewdrop:AddLine(
'text', "Hello, world!",
'hasArrow', true,
'hasSlider', true
'sliderValue', 0.5
)
- sliderFunc
-
- function(value) - function to call when the value changed.
- Remarks:
-
Requires that hasArrow and hasSlider are true.
If sliderFunc(value) returns a string, then that is used to set the current value string on the slider.
value will always be within [0, 1].
- Example:
- dewdrop:AddLine(
'text', "Hello, world!",
'hasArrow', true,
'hasSlider', true
'sliderFunc', function(value)
print("New value: " .. value)
return format("%.0f%%", value)
end
)
- textHeight
-
- Number - height of the text.
- Remarks:
-
If not provided, 10 is assumed.
- Example:
- dewdrop:AddLine(
'text', "Hello, world!",
'textHeight', 10
)
- justifyH
-
- String - horizontal justification of the text.
- Remarks:
-
Must be either "LEFT", "RIGHT", or "CENTER"
If not provided, "LEFT" is assumed.
- Example:
- dewdrop:AddLine(
'text', "Hello, world!",
'justifyH', "CENTER"
)
- tooltipTitle
-
- String - title of the newbie tooltip.
- Remarks:
-
If not provided, the tooltip won't show up.
- Example:
- dewdrop:AddLine(
'text', "Hello, world!",
'tooltipTitle', "Hello"
)
- tooltipText
-
- String - text of the newbie tooltip.
- Remarks:
-
Requires tooltipTitle to be set.
- Example:
- dewdrop:AddLine(
'text', "Hello, world!",
'tooltipTitle', "Hello",
'tooltipText', "world!"
)
- closeWhenClicked
-
- Boolean - whether to close menu when clicked.
- Remarks:
-
This closes the whole menu, not just the one level.
- Example:
- dewdrop:AddLine(
'text', "Hello, world!",
'closeWhenClicked', true
)