AceConfig-3.0 Options Tables
The AceOptions table format is a standardized way of representing the commands available to control an addon.
An example table, very minimalistic:
myOptionsTable = { type = "group", args = { enable = { name = "Enable", desc = "Enables / disables the addon", type = "toggle", set = function(info,val) MyAddon.enabled = val end, get = function(info) return MyAddon.enabled end }, moreoptions={ name = "More Options", type = "group", args={ -- more options go here } } } }
The Basics
Every option table has to start with a head group
node. It can have a name and an icon, but only the group-type and the args
table are required.
You can nest groups as deep as you need them to be, and include any options on any level. Of course not everything makes sense from a UI design perspective.
Nearly all parameters can be inherited through the table tree. For example, you can define one get
handler on the group, and all member nodes (or member nodes of sub-groups) will use this get
handler, unless overriden.
Currently inherited are: set, get, func, confirm, validate, disabled, hidden
The keys used in the option tables can contain all printable chars. If you use spaces in the keys, and intend to use your option table with a Command Line interface like AceConfigCmd-3.0, make sure your keys do not collide, as AceConfigCmd-3.0 maps the spaces to underscores, so "foo bar" and "foo_bar" would collide.
Most parameters can also be a function reference, which is called when the value is requested. Every function called by AceConfig will be called with an info table as its first parameter. The info table contains information about the current position in the tree, the type of UI displaying the options, and the options table itself.
For more details on the info table, see Callback Arguments.
Common Parameters
The following parameters apply to all types of nodes and groups, and control the general layout of the options.
- name (string|function) - Display name for the option
- desc (string|function) - description for the option (or nil for a self-describing name)
- descStyle (string) - "inline" if you want the description to show below the option in a GUI (rather than as a tooltip). Currently only supported by AceGUI "Toggle".
- validate (methodname|function|false) - validate the input/value before setting it. return a string (error message) to indicate error.
- confirm (methodname|function|boolean) - prompt for confirmation before changing a value
- true - display "name - desc", or contents of .confirmText
- function - return a string (prompt to display) or true (as above), or false to skip the confirmation step
- order (number|methodname|function) - relative position of item (default = 100, 0=first, -1=last)
- disabled (methodname|function|boolean) - disabled but visible
- hidden (methodname|function|boolean) - hidden (but usable if you can get to it, i.e. via commandline)
- guiHidden (boolean) - hide this from graphical UIs (dialog, dropdown)
- dialogHidden (boolean) - hide this from dialog UIs
- dropdownHidden (boolean) - hide this from dropdown UIs
- cmdHidden (boolean)- hide this from commandline
- Note that only
hidden
can be a function, the specialized hidden cases cannot.
- icon (string|function) - path to icon texture
- iconCoords (table|methodname|function) - arguments to pass to SetTexCoord, e.g. {0.1,0.9,0.1,0.9}.
- handler (table) - object on which getter/setter functions are called if they are declared as strings rather than function references
- type (string) - "execute", "input", "group", etc; see below
- width (string) - "double", "half", "full", "normal", or numeric, in a GUI provide a hint for how wide this option needs to be. (optional support in implementations)
- default is nil (not set)
- double, half - increase / decrease the size of the option
- full - make the option the full width of the window
- normal - use the default widget width defined for the implementation (useful to overwrite widgets that default to "full")
- any number - multiplier of the default width, ie. 0.5 equals "half", 2.0 equals "double"
Item Types
execute
A execute option will simply run 'func'. In a GUI, this would be a button.
If image is set, it'll display a clickable image instead of a default GUI button.
- func (function|methodname) - function to execute
- image (string|function) - path to image texture, if this is a function it can optionally return the width and height of the image as the 2nd and 3rd value, these will be used instead of imageWidth and imageHeight.
- imageCoords (table|methodname|function) - arguments to pass to SetTexCoord, e.g. {0.1,0.9,0.1,0.9}.
- imageWidth (number) - Width of the displayed image
- imageHeight (number) - Height of the displayed image
input
A simple text input, with an optional validate string or function to match the text against.
- get (function|methodname) - getter function
- set (function|methodname) - setter function
- multiline (boolean|integer) - if true will be shown as a multiline editbox in dialog implementations (Integer = # of lines in editbox)
- pattern (string) - optional validation pattern. (Use the validate field for more advanced checks!)
- usage (string) - usage string (displayed if pattern mismatches and in console help messages)
toggle
A simple checkbox
- get (function|methodname) - getter function
- set (function|methodname) - setter function
- tristate (boolean) - Make the toggle a tri-state checkbox. Values are cycled through unchecked (false), checked (true), greyed (nil) - in that order.
range
A option for configuring numeric values in a specific range. In a GUI, a slider.
- min - min value
- max - max value
- softMin - "soft" minimal value, used by the UI for a convenient limit while allowing manual input of values up to min/max
- softMax - "soft" maximal value, used by the UI for a convenient limit while allowing manual input of values up to min/max
- step - step value: "smaller than this will break the code" (default=no stepping limit)
- bigStep - a more generally-useful step size. Support in UIs is optional.
- get (function|methodname) - getter function
- set (function|methodname) - setter function
- isPercent (boolean) - represent e.g. 1.0 as 100%, etc. (default=false)
Note:
The "step" checking will only work if you specify valid values for "min" and "max". Especially when using "softMin" and "softMax", "min" and "max" are still required for "step" to function!
If no "min" or "max" are specified, the manual input of the range control will accept any and all values!
select
Only one of the values can be selected. In a dropdown menu implementation it would likely be a radio group, in a dialog likely a dropdown combobox.
- values (table|function) - [key]=value pair table to choose from, key is the value passed to "set", value is the string displayed
- sorting (table|function) - Optional sorted array-style table with the keys of the values table as values to sort the options.
- get (function|methodname) - getter function
- set (function|methodname) - setter function
- style - "dropdown", "radio" (optional support in implementations)
multiselect
Basically multiple "toggle" elements condensed into a group of checkboxes, or something else that makes sense in the interface.
- values (table|function) - [key]=value pair table to choose from, key is the value passed to "set", value is the string displayed
- get (function|methodname) - will be called for every key in values with the key name as last parameter
- set (function|methodname) - will be called with keyname, state as parameters
- tristate (boolean) - Make the checkmarks tri-state. Values are cycled through unchecked (false), checked (true), greyed (nil) - in that order.
color
Opens a color picker form, in GUI possibly a button to open that.
- get (function|methodname) - getter function
- set (function|methodname) - setter function
- hasAlpha (boolean) - indicate if alpha is adjustable (default false)
Getter/setter functions use 4 arguments/returns: r,g,b,a. If hasAlpha is false/nil, alpha will always be set() as 1.0.
keybinding
- get (function|methodname) - getter function
- set (function|methodname) - setter function
header
A heading.
In commandline and dropdown UIs shows as a heading, in a dialog UI it will additionaly provide a break in the layout.
- name is the text to display in the heading.
description
A paragraph of text to appear next to other options in the config, optionally with an image in front of it.
- name is the text to display
- fontSize is the size of the text. Three pre-defined values are allowed: "large", "medium", "small". Defaults to "small".
- image (string|function) - path to image texture, if this is a function it can optionally return the width and height of the image as the 2nd and 3rd value, these will be used instead of imageWidth and imageHeight.
- imageCoords (table|methodname|function) - arguments to pass to SetTexCoord, e.g. {0.1,0.9,0.1,0.9}.
- imageWidth (number) - Width of the displayed image
- imageHeight (number) - Height of the displayed image
group
The first table in an AceOptions table is implicitly a group. You can have more levels of groups by simply adding another table with type="group" under the first args table.
- args subtable with more items/groups in it
- plugins subtable, containing named tables with more args in them, e.g.
plugins["myPlugin"]={ option1={...}, option2={...}, group1={...} } plugins["otherPlugin"]={...}
This allows modules and libraries to easily add more content to an addon's options table.
- childGroups argument, decides how children groups of this group are displayed:
- "tree" (the default) - as child nodes in a tree control
- "tab" - as tabs
- "select" - as a dropdown list
Only dialog-driven UIs are assumed to behave differently for all types.
- inline (boolean) - show as a bordered box in a dialog UI, or at the parent's level with a separate heading in commandline and dropdown UIs.
- cmdInline (boolean) - as above, only obeyed by commandline
- guiInline (boolean) - as above, only obeyed by graphical UIs
- dropdownInline (boolean) - as above, only obeyed by dropdown UIs
- dialogInline (boolean) - as above, only obeyed by dialog UIs
Callback Handling
- For each set/get/func/validate/confirm callback attempted, the tree will ALWAYS be traversed toward the root until such a directive is found. Similarly, if callbacks are given as strings, the tree will be traversed to find a "handler" argument.
- To declare that an inherited value is NOT to be used even though a parent has it, set it to false. This is primarily useful for validate and confirm, but is allowed for all inherited values including "handler".
Callback Arguments
All callback receive a standardized set of arguments:
(info, value[, value2, ...]).
In detail, the info table contains:
- An "options" member pointing at the root of the options table
- The name of the slash command at position 0, or empty string ("") if not a slash.
- The name of the first group traversed into at position 1
- The node name at position n (may be 1 if at the root level)
- Hint: Use info[#info] to get the leaf node name, info[#info-1] for the parent, and so on!
- An "arg" member if set in the node.
- A "handler" member which is the handler object for the current option.
- A "type" member which is the type of the current option.
- An "option" member pointing at the current option.
- "uiType" and "uiName" members, which are the same as the parameters passed when retrieving the options table from AceConfigRegistry-3.0
The callback may not assume ownership of the infotable. The config parser is assumed to reuse it. It may also contain more members, but these are outside the spec and may change at any time - do not use information in undocumented infotable members.
! Callbacks on the form handler:"methodname" will of course be passed the handler object as the first ("self") argument.
Callback Example
local function mySetterFunc(info, value) db[info[#info]] = value -- we use the db names in our settings for Zzz print("The " .. info[#info] .. " was set to: " .. tostring(value) ) end
Custom controls
You can register a custom control with AceGUI and use it in an AceConfigDialog displayed table. This is currently supported for almost all simple control types, except "select" with style="radio", but not for groups or other complex types.
This method is currently only supported in AceConfigDialog-3.0, using the dialogControl attribute.
Example usage with AceGUI-3.0-SharedMediaWidgets:
local media = LibStub("LibSharedMedia-3.0") self.options = { type = "group", args = { texture = { type = "select", name = "Texture", desc = "Set the statusbar texture.", values = media:HashTable("statusbar"), dialogControl = "LSM30_Statusbar", }, } }
Widget API requred to be implemented by custom AceGUI widgets when used with AceConfigDialog-3.0 (this part of the spec is not finalised)
- type = 'input'
- :SetDisabled(disabled)
- disabled - boolean, whether the control is disabled
- :SetLabel(text)
- text - string, The name of the option to be displayed
- :SetText(text)
- text - string, the contents of the EditBox.
- Callback OnEnterPressed(text), fired when the text has changed and should be saved.
- :SetDisabled(disabled)
- type = 'select'
- :SetDisabled(disabled)
- diasbled - boolean, whether the control is disabled
- :SetValue(value)
- value - string, The value that is currently selected.
- :SetList(list)
- list - table, A { value = text } table of the options to be displayed.
- :SetLabel(text)
- text - string, The name of the option to be displayed
- Callback OnValueChanged(value), fired when a value is selected, this must be a key from the list table.
- :SetDisabled(disabled)
Both should also fire OnEnter and OnLeave callbacks for tooltips to work.
Hi everybody!
Is there a way to influence the text alignment in a select -> dropdown item? I would like to so something similar to a justifyH = "LEFT" to align the text in the dropdown menu to the left. Is this possible?
Thanks in advance!
How does the command line/options table handle Localization?
When using groups is it possible to use Blizzards Addon "group"/subpage system? So that there are pages on the very left and not inside the actual config frame.
In reply to Danielps1:
I'm trying to create a growing list of options.
Each time the "Add New" button is clicked, a new row of options should be added to the end of the table. I'm not sure how to make a "group" option appear like this, though.
12345
15
Getting an error thrown on login:
Date: 2018-08-11 12:36:13
ID: 1
Error occured in: Global
Count: 1
Message: ..\AddOns\Ace3\AceEvent-3.0\AceEvent-3.0.lua line 33:
Attempt to register unknown event "TRADE_SKILL_UPDATE"
Debug:
(tail call): ?
(tail call): ?
[C]: RegisterEvent()
Ace3\AceEvent-3.0\AceEvent-3.0.lua:33: OnUsed()
...Ons\Ace3\CallbackHandler-1.0\CallbackHandler-1.0.lua:168: RegisterEvent()
AckisRecipeList\Core.lua:421:
AckisRecipeList\Core.lua:416
(tail call): ?
[C]: ?
[string "safecall Dispatcher[1]"]:9:
[string "safecall Dispatcher[1]"]:5
(tail call): ?
Ace3\AceAddon-3.0\AceAddon-3.0.lua:558: EnableAddon()
Ace3\AceAddon-3.0\AceAddon-3.0.lua:651:
Ace3\AceAddon-3.0\AceAddon-3.0.lua:636
[C]: ?
[C]: LoadAddOn()
..\FrameXML\UIParent.lua:445: UIParentLoadAddOn()
..\FrameXML\UIParent.lua:488: CombatLog_LoadUI()
..\FrameXML\UIParent.lua:1193:
..\FrameXML\UIParent.lua:1089
[C]: ?
In reply to Zallanon:
Can't figure out where to post lua errors, so here goes:
Date: 2018-10-18 17:29:48
ID: 3
Error occured in: Global
Count: 1
Message: ..\AddOns\Ace3\AceEvent-3.0\AceEvent-3.0.lua line 33:
Attempt to register unknown event "TRADE_SKILL_UPDATE"
Debug:
[C]: RegisterEvent()
Ace3\AceEvent-3.0\AceEvent-3.0.lua:33: OnUsed()
...Ons\Ace3\CallbackHandler-1.0\CallbackHandler-1.0.lua:168: RegisterEvent()
AckisRecipeList\Core.lua:421:
AckisRecipeList\Core.lua:416
(tail call): ?
[C]: ?
[string "safecall Dispatcher[1]"]:9:
[string "safecall Dispatcher[1]"]:5
(tail call): ?
Ace3\AceAddon-3.0\AceAddon-3.0.lua:558: EnableAddon()
Ace3\AceAddon-3.0\AceAddon-3.0.lua:651:
Ace3\AceAddon-3.0\AceAddon-3.0.lua:636
[C]: ?
[C]: LoadAddOn()
..\FrameXML\UIParent.lua:446: UIParentLoadAddOn()
..\FrameXML\UIParent.lua:565: TimeManager_LoadUI()
..\FrameXML\UIParent.lua:1192:
..\FrameXML\UIParent.lua:1090
Locals:
None
AddOns:
Swatter, v8.0.6162 (SwimmingSeadragon)
Ace3, v
AckisRecipeList, v7.3.0.1
AckisRecipeListQuickScan, v7.3.0.1
ACP, vr259
AdvancedInterfaceOptions, v1.2.8
Altoholic, vr190
Atlas, vv1.44.03
AtlasArena, vv1.07.02
AtlasBattlegrounds, vv1.44.00
AtlasBurningCrusade, vv1.44.00
AtlasCataclysm, vv1.44.00
AtlasClassicWoW, vv1.44.00
AtlasClassOrderHalls, vv1.44.00
AtlasDungeonLocs, vv1.44.00
AtlasLegion, vv1.44.00
AtlasMistsofPandaria, vv1.44.00
AtlasOutdoorRaids, vv1.44.00
AtlasScenarios, vv1.44.00
AtlasTransportation, vv1.44.00
AtlasWarlordsofDraenor, vv1.44.00
AtlasWorldEvents, vv3.24
AtlasWrathoftheLichKing, vv1.44.00
AtlasLoot, vv8.08.01
AtlasLootBattleforAzeroth, vv8.08.01
AtlasLootBurningCrusade, vv8.08.01
AtlasLootCataclysm, vv8.08.01
AtlasLootClasses, vv3.1
AtlasLootClassic, vv8.08.01
AtlasLootLegion, vv8.08.01
AtlasLootMistsofPandaria, vv8.08.01
AtlasLootSource, vv0.3
AtlasLootWarlordsofDraenor, vv8.08.01
AtlasLootWrathoftheLichKing, vv8.08.01
AtlasMajorCitiesEnhanced, vv1.16
AucAdvanced, v8.0.6122 (SwimmingSeadragon)
auccheapsearcher, v20180721
AucFilterBasic, v8.0.6149 (SwimmingSeadragon)
AucStatHistogram, v8.0.6151 (SwimmingSeadragon)
AucStatiLevel, v8.0.6155 (SwimmingSeadragon)
AucStatPurchased, v8.0.6152 (SwimmingSeadragon)
AucStatSimple, v8.0.6153 (SwimmingSeadragon)
AucStatStdDev, v8.0.6154 (SwimmingSeadragon)
AucUtilFixAH, v8.0.6156 (SwimmingSeadragon)
AutoTurnIn, v7.0.9
BarrelsOEasy, v1.1.11
BattlePetBreedID, vr179
BeanCounter, v8.0.6157 (SwimmingSeadragon)
CanIMogIt, v8.0.0v1.13
CollectionShop, v3.06
CurrencySorter, v
DataStore, vr65
DataStoreAchievements, vr47
DataStoreAgenda, vr29
DataStoreAuctions, vr50
DataStoreCharacters, vr43
DataStoreContainers, vr59
DataStoreCrafts, vr82
DataStoreCurrencies, vr38
DataStoreGarrisons, vr24
DataStoreInventory, vr53
DataStoreMails, vr52
DataStorePets, vr44
DataStoreQuests, vr46
DataStoreReputations, vr43
DataStoreSpells, vr32
DataStoreStats, vr31
DataStoreTalents, vr61
DBMCore, v8.0.13
DBMDefaultSkin, v
DBMStatusBarTimers, v
DBMVPVEM, v8.0.4
DejaCharacterStats, v800r103
Details, v
DetailsDmgRank, v
DetailsDpsTuning, v
DetailsEncounterDetails, v
DetailsRaidCheck, v
DetailsStreamer, v
DetailsTimeAttack, v
DetailsTinyThreat, v
DetailsVanguard, v
FishingBuddy, v1.9.19
GarrisonCommanderBroker, v3.0.0 1.1.0
GnomeSequencer, v7.3.0.1
Grail, v097
GrailQuestsenUS, v27178
HandyNotes, vv1.5.3
HandyNotesArgus, vv0.10
HandyNotesBattleForAzerothTreasures, v1
HandyNotesBrokenShore, vv1.29
HandyNotesCamelFigurines, v1.3
HandyNotesDraenorTreasures, v1.21
HandyNotesHigherDimensionalLearning, v1
HandyNotesHigherLearning, v8.0.0.0
HandyNotesKosumoth, v1
HandyNotesLegionRaresTreasures, v1.1
HandyNotesLegionTreasures, v1
HandyNotesLorewalkers, v1
HandyNotesLostAndFound, v1
HandyNotesLunarFestival, vv1.5
HandyNotesSpecialNPCsEtc, v1.1.1-Beta
HandyNotesSummerFestival, vv1.5
HandyNotesSuramarLeylines, v1
HandyNotesSuramarTelemancy, v1
HandyNotesTimelessIsleChests, v1.20
HandyNotesTimelessTreasures, v1.0.7
HealBot, v8.0.1.0
HiddenArtifactTracker, v
KeystoneManager, v8.0.2
LibSharedMedia30, v3.0-104
MacroToolkit, vv7.3.0.2
MasterPlanA, vA
MikScrollingBattleText, v5.7.149
MinimalArchaeology, v8.0.12.1
NPCScan, v8.0.1.13
OmniCC, v8.0.9
Outfitter, v5.20.3
Overachiever, v1.0.4
OverachieverCache, v1.0.4
Paste, v1.4.10
PersonalLootHelper, v2.17
PetBattleTeams, v3.3.10
PetTracker, v8.0.6
PetTrackerBreeds, v8.0.6
PetTrackerSwitcher, v8.0.6
PetTrackerUpgrades, v8.0.6
PremadeAutoAccept, v1.0.1
RSA, vr508-Release
RSADruid, v
SavedInstances, v8.0.6
SellJunk, v3.0.16
SharedMedia, v3.1.0-191
SharedMediaAdditionalFonts, v1.0.26
SharedMediaAdditionalSounds, v7.0
SilentWorldQuestOptions, v8.0.1
SilverDragon, vv4.0.13
SilverDragonBattleForAzeroth, vv4.0.13
SilverDragonBurningCrusade, vv4.0.13
SilverDragonCataclysm, vv4.0.13
SilverDragonLegion, vv4.0.13
SilverDragonMists, vv4.0.13
SilverDragonVanilla, vv4.0.13
SilverDragonWarlords, vv4.0.13
SilverDragonWrath, vv4.0.13
Stubby, v8.0.6161 (SwimmingSeadragon)
Titan, v5.14.12.80000
TitanBag, v5.14.12.80000
TitanClock, v5.14.12.80000
TitanGold, v5.14.12.80000
TitanLocation, v5.14.12.80000
TitanLootType, v5.14.12.80000
TitanPerformance, v5.14.12.80000
TitanRepair, v5.14.12.80000
TitanVolume, v5.14.12.80000
TitanXP, v5.14.12.80000
TomTom, vv80001-1.0.2
TradeSkillInfo, vv2.4.1
TransmogShop, v2.01
WorldQuestTracker, v
xanMortarPestle, v3.2
BlizRuntimeLib_enUS v8.0.1.80000 <none>
(ck=1274)
It probably sounds silly but I can't figure out how to call a getter from command line? I am doing an example WelcomeHome with Ace3 and have both a getter and a setter in option:
This addon works fine. I can set a new message by calling a setter: "/ma msg <new message>". I can't display the current message. I tried "/ma msg" but it simply assigns an empty string to "message" var. So I always call a setter when I use command "/ma msg".
In reply to Melenkurion:
Hi and thx for all our work, to start with...
Is there a Ace3 project for classic, taht I might hav missed?
thx again,
Kabulla
In reply to Kabulla:
There is not a seperate Ace3 for Classic. Use the current one.
I have a couple of sliders (type = "range") for which I'd like to set a default value so the first time they are displayed, they show the default.
For type = "toggle", I can set the value and the first time the options are displayed, they reflect that value. I looked in the documentation and didn't find an answer.
In reply to bsmorgan:
clearly it's been some years since this was posted. prob few will have this issue but...
the reason this happens is that there is a mismatch in the datatype coming from the get function, as relates to the min,max values.
in other words.. when dealing with range widget, min,max and get() value need to be the same data type.
example:
if your min and max are both integers
and your get() returns a string
a default value will not be displayed in the widget