View Single Post
04-12-24, 10:02 PM   #10
Hubb777
A Flamescale Wyrmkin
 
Hubb777's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2024
Posts: 122
Looks like I didn't succeed =(

I added this to the code of the panel that I want to open:
Lua Code:
  1. local category = Settings.RegisterCanvasLayoutCategory(panel, "MyAddonOptionsPanel")
  2.     Settings.RegisterAddOnCategory(category)

I also changed the button code on the minimap
Lua Code:
  1. local addonName, addon = ...
  2. -- Create the minimap icon
  3. local addonName = "MyAddon"
  4. local LDB = LibStub("LibDataBroker-1.1")
  5. local minimapIcon = LibStub("LibDBIcon-1.0")
  6.  
  7. -- Create a data broker object for the addon
  8. local dataBroker = LDB:NewDataObject(addonName, {
  9.     type = "data source",
  10.     icon = "Interface\\AddOns\\ZamestoTV_GoldFarm\\Icons\\goblin", -- Replace with your addon's icon path
  11.     OnClick = function(self, button)
  12.         if button == "LeftButton" then
  13.             local categoryID = MyAddonOptionsPanel:GetID() -- Replace with your addon's options panel ID
  14.             Settings.OpenToCategory(categoryID)
  15.         end
  16.     end,
  17. })
  18.  
  19. -- Register the data broker with the minimap icon
  20. minimapIcon:Register(addonName, dataBroker, {
  21.     hide = false,
  22.     minimapPos = 180, -- Set the position on the minimap (in degrees)
  23. })
  24.  
  25. -- Add a function to set the category ID for opening
  26. function addon:SetOptionsPanelCategory(categoryID)
  27.     MyAddonOptionsPanel:SetID(categoryID)
  28. end

As a result, the button works without changes (using the example with the pictures above)

Last edited by Hubb777 : 04-12-24 at 10:49 PM.
  Reply With Quote