Addon compartment

From Warcraft Wiki
Jump to navigation Jump to search
The addon compartment since Patch 10.0.7. The compartment only appears if at least one button has been registered.

Introduced in World of Warcraft: Dragonflight, 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: 100206
## 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, menuButtonFrame)
     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 compatible for use with UIDropDownMenu button initialization.

MyAddOn.lua

 AddonCompartmentFrame:RegisterAddon({
     text = "My Addon",
     icon = "Interface\\Icons\\TEMP.blp",
     notCheckable = true,
     func = function()
         print("Hello from the addon compartment!")
     end,
 })


Issues

Currently has an issue whereby a disabled Addon will appear in the addon compartment if it is enabled on a different character.

See Compartment Bug.[2]

Patch changes

  • Dragonflight Patch 10.1.0 (2023-05-02): Addons can now register with the compartment through TOC metadata fields.
  • Dragonflight Patch 10.0.0 (2022-10-25): Added.

References