Hi all. I created a button on the minimap. But I can’t get it to open another LUA file.
the button itself (triggered by LMB).
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\\TEST_ADDON\\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
print("Toggle options panel")
end
The frame that the button should open
Lua Code:
local panel = CreateFrame("Frame", "MyAddonOptionsPanel", InterfaceOptionsFrame)