Thread Tools Display Modes
Prev Previous Post   Next Post Next
01/27/17, 02:31 PM   #1
Hoft
 
Hoft's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2016
Posts: 17
Menu getFunc

I have a problem with simple code ((
My menu allways show only default value!
setFunc works right and changes variable
ZO_SavedVars works right and load/saves variable
When I change variable by menu, key bind, slash command, or any other way and returns to menu… it allways show default value! Where is my mistake?

Code:
Addon = {
	name = "Addon",
	Menu = {},
	Vars = {},
	Defaults = {
		["OnOff"] = true,
	}
};

function Addon.Menu()
	local options = {
		{	type	= "header",
			name	= "Options",
			width	= "full"
		},
		{	type	= "checkbox",
			name	= "Enables add-on",
			tooltip	= "",
			getFunc	= function() return Addon.Vars.OnOff end,
			setFunc	= function(value) Addon.Vars.OnOff =value end,
			default	= Addon.Defaults.OnOff,
		},
	local menu = LibStub("LibAddonMenu-2.0")
	local panel = {
		type = "panel",
		name = "Add-on",
		displayName = "Add-on",
		author = "autor",
		version = "1",
	}
	menu:RegisterAddonPanel("AddonMenu", panel)
	menu:RegisterOptionControls("AddonMenu", options)
end

function Addon.OnAddOnLoaded( eventCode, addonName )
	if (addonName ~= Addon.name) then return end

	EVENT_MANAGER:UnregisterForEvent(Addon.name, EVENT_ADD_ON_LOADED)

	Addon.Vars = ZO_SavedVars:NewAccountWide( "Addon_Settings" , version , nil , Addon.Defaults )
	Addon.Menu()
end

Last edited by Hoft : 01/27/17 at 02:35 PM.
  Reply With Quote
 

ESOUI » Developer Discussions » General Authoring Discussion » Menu getFunc


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