Thread Tools Display Modes
Prev Previous Post   Next Post Next
04-11-24, 05:13 AM   #1
Hubb777
A Flamescale Wyrmkin
 
Hubb777's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2024
Posts: 122
Button on the minimap

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:
  1. local addonName, addon = ...
  2. local addonName = "MyAddon"
  3. local L = {} -- Localization table (if needed)
  4.  
  5. -- Check if the addon object is already registered
  6. if not LibStub("LibDBIcon-1.0", true):GetMinimapButton(addonName) then
  7.     -- Create the minimap icon
  8.     local icon = LibStub("LibDBIcon-1.0")
  9.     local minimapIcon = LibStub("LibDataBroker-1.1"):NewDataObject(addonName, {
  10.         type = "data source",
  11.         text = addonName,
  12.         icon = "Interface\\AddOns\\TEST_ADDON\\Icons\\goblin", -- Replace with path to your icon
  13.         OnClick = function(_, button)
  14.             if button == "LeftButton" then
  15.                 MyAddonOptionsPanel_Toggle() -- Open or close the options panel
  16.             end
  17.         end,
  18.         OnTooltipShow = function(tooltip)
  19.             tooltip:SetText(addonName)
  20.             tooltip:AddLine("Click to open options")
  21.             tooltip:Show()
  22.         end,
  23.     })
  24.  
  25.     -- Register the minimap icon
  26.     icon:Register(addonName, minimapIcon, MyAddonOptionsPanelDB) -- Replace MyAddonDB with your saved variables table name
  27. end
  28.  
  29. -- Define the function to toggle the options panel
  30. function MyAddonOptionsPanel_Toggle()
  31.     -- Add code to open or close the options panel here
  32.     print("Toggle options panel")
  33. end


The frame that the button should open

Lua Code:
  1. local panel = CreateFrame("Frame", "MyAddonOptionsPanel", InterfaceOptionsFrame)
  Reply With Quote
 

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Button on the minimap


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off