I need the settings menu for my addon to open.
How it works for me now (a menu with game settings opens)
How I want it to work (my addon settings should open)
Here is my final code
Lua Code:
local addonName, addon = ...
local addonName = "MyAddon"
local L = {} -- Localization table (if needed)
-- Check if the addon object is already registered
if not LibStub("LibDBIcon-1.0", true):GetMinimapButton(addonName) then
-- Create the minimap icon
local icon = LibStub("LibDBIcon-1.0")
local minimapIcon = LibStub("LibDataBroker-1.1"):NewDataObject(addonName, {
type = "data source",
text = addonName,
icon = "Interface\\AddOns\\ZamestoTV_GoldFarm\\Icons\\goblin", -- Replace with path to your icon
OnClick = function(_, button)
if button == "LeftButton" then
MyAddonOptionsPanel_Toggle() -- Open or close the options panel
end
end,
OnTooltipShow = function(tooltip)
tooltip:SetText(addonName)
tooltip:AddLine("Click to open options")
tooltip:Show()
end,
})
-- Register the minimap icon
icon:Register(addonName, minimapIcon, MyAddonOptionsPanelDB) -- Replace MyAddonDB with your saved variables table name
end
-- Define the function to toggle the options panel
function MyAddonOptionsPanel_Toggle()
-- Add code to open or close the options panel here
InterfaceOptionsFrame_OpenToCategory("MyAddonOptionsPanel") -- Open options panel to a specific category
print("Toggle options panel")
end
-- Define the function to toggle the panel visibility
local function TogglePanel(panel)
if panel:IsShown() then
panel:Hide()
else
panel:Show()
end
end