This lib creates buttons in the top right of the chat window.
To create a new button, simply execute the following code:
Parameters:
- name: the name for the button, it is only used for sorting the buttons. The name should follow this regex:
- imagePath: the path for the icon that the button should have. By default the alpha of the icon is changed onHover, but you can also add another icon for the onHover, onPressed, onDisabled and onDisabledPressed (see examples below).
- tooltip: the tooltip that should be shown next to the icon when hovering over it, this parameter is optional.
- func: the function that should be executed when the button is clicked
Code:
LibChatMenuButton.addChatButton(<string>name, <string/table>imagePath, <string>tooltip, <function>func)
Examples:
Code:
local button1 = LibChatMenuButton.addChatButton("myButton1", "imagePath", "tooltip", function() d("Hi") end)
local button2 = LibChatMenuButton.addChatButton("myButton2", "imagePath", nil, function() d("Hi") end)
local button3 = LibChatMenuButton.addChatButton("myButton3", {"imagePath", "imagePathHover", "imagePathPressed", "imagePathDisabled", "imagePathDisabledPressed"}, "tooltip", function() d("Hi") end)
Edit a button:
Parameters:
- values: a key - value list of the parameters that should be changed
Code:
local button1 = LibChatMenuButton.addChatButton("myButton1", "path/to/icon", "tooltip", function() d("Hi") end)
button1:edit({["tooltip"] = "newTooltip", ["imagePath"] = "path/to/new/icon"})
-- ! imagePath is a string here, if you want to edit the onHover - image you need to change the imagePathHover parameter
-- parameters that can be changed: name, imagePath, imagePathHover, tooltip, func
Hide a button:
Code:
local button1 = LibChatMenuButton.addChatButton("myButton1", "path/to/icon", "tooltip", function() d("Hi") end)
button1:hide()
Show a button:
Code:
local button1 = LibChatMenuButton.addChatButton("myButton1", "path/to/icon", "tooltip", function() d("Hi") end)
button1:show()
Enable a button:
Code:
local button1 = LibChatMenuButton.addChatButton("myButton1", "path/to/icon", "tooltip", function() d("Hi") end)
button1:enable()
Disable a button:
Code:
local button1 = LibChatMenuButton.addChatButton("myButton1", "path/to/icon", "tooltip", function() d("Hi") end)
button1:disable()