Addon compartment
The addon compartment is a dropdown menu accessible from the minimap that provides a list of clickable buttons registered by installed addons. This is intended to provide an alternative to minimap buttons, suitable for simple use cases such as toggling a UI panel related to an addon.
Integration
Addons can register entries into the addon compartment dropdown through the following methods.
Automatic registration
Addons can define the following metadata fields within their TOC file to control the automatic registration of their addon into the compartment. If the addon is load-on-demand, it will be loaded automatically if any of the functions specified in metadata fields need to be called.
Field Name | Example Value | Description |
---|---|---|
AddonCompartmentFunc | MyAddOn_OnAddonCompartmentClick |
The name of a global function to be executed when the compartment dropdown entry is clicked. This field is required. |
AddonCompartmentFuncOnEnter | MyAddOn_OnAddonCompartmentEnter |
The name of a global function to be executed when the compartment dropdown entry is highlighted. Optional. |
AddonCompartmentFuncOnLeave | MyAddOn_OnAddonCompartmentLeave |
The name of a global function to be executed when the compartment dropdown entry is no longer highlighted. Optional. |
IconTexture | Interface\Icons\TEMP.blp |
The full path or file ID of a texture file to show as an icon in the compartment dropdown. Optional. |
IconAtlas | TaskPOI-Icon |
The name of a texture atlas to use as the icon. Optional, and has a lower priority than the IconTexture field if both are set. |
The example below demonstrates the use of these TOC fields.
MyAddOn.toc
## Interface: 110002 ## Title: My Addon ## Notes: Does something neat ## Author: Your Name ## AddonCompartmentFunc: MyAddOn_OnAddonCompartmentClick ## AddonCompartmentFuncOnEnter: MyAddOn_OnAddonCompartmentEnter ## AddonCompartmentFuncOnLeave: MyAddOn_OnAddonCompartmentLeave ## IconTexture: Interface\Icons\TEMP.blp MyAddOn.lua
MyAddOn.lua
function MyAddOn_OnAddonCompartmentClick(addonName, buttonName)
print("Hello from the addon compartment, clicked with " .. buttonName)
end
function MyAddOn_OnAddonCompartmentEnter(addonName, menuButtonFrame)
print("Entered my button!")
end
function MyAddOn_OnAddonCompartmentLeave(addonName, menuButtonFrame)
print("Left my button!")
end
Manual registration
Manual registration into the addon compartment can be performed by calling the AddonCompartmentFrame:RegisterAddon function, supplying it a table similar to legacy UIDropDownMenu button initialization.
MyAddOn.lua
AddonCompartmentFrame:RegisterAddon({
text = "My Addon",
icon = "Interface\\Icons\\TEMP.blp",
notCheckable = true,
func = function(button, menuInputData, menu)
local buttonName = menuInputData.buttonName;
print("Hello from the addon compartment! You clicked " .. buttonName .. "!")
end,
funcOnEnter = function(button)
MenuUtil.ShowTooltip(button, function(tooltip)
tooltip:SetText("My cool item!")
end)
end,
funcOnLeave = function(button)
MenuUtil.HideTooltip(button)
end,
})
Patch changes
- Patch 11.0.0 (2024-07-23): Function signatures for Click handlers changed. Automatic registrations no longer receive a third
menuButtonFrame
parameter. Manual registrations now receive input data packaged as a table as the second argument offunc
. - Patch 10.1.0 (2023-05-02): Addons can now register with the compartment through TOC metadata fields.
- Patch 10.0.0 (2022-10-25): Added.
|