Quantcast [AceConfig] Grey out options when disabled - WoWInterface
Thread Tools Display Modes
09-01-18, 07:54 AM   #1
Lyak
A Cyclonian
Join Date: Jul 2018
Posts: 45
[AceConfig] Grey out options when disabled

Hi all,

I am to learn AceConfig and got a question regarding greying options out when disabled.

So, I currently have the following:
Lua Code:
  1. local enable = true
  2. local size = 15
  3.  
  4. local options = {
  5.     type = "group",
  6.     childGroups = "tab",
  7.     name = "Test " .. A.version,
  8.     arg = "Test",
  9.     args = {
  10.         enable = {
  11.             order = 1,
  12.             type = "toggle",
  13.             name = "Enable",
  14.             get = function()
  15.                 return enable;
  16.             end,
  17.             set = function(_, value)
  18.                 enable = value;
  19.             end,
  20.             disabled = function()
  21.  
  22.             end,
  23.         },
  24.         size = {
  25.             order = 2,
  26.             type = "range",
  27.             name = "Size",
  28.             min = 5,
  29.             max = 30,
  30.             step = 1,
  31.             get = function()
  32.                 return size;
  33.             end,
  34.             set = function(_, value)
  35.                 size = value;
  36.             end,
  37.         },
  38.     },
  39. }

It seems like I could grey out the size option with enable's disabled function, but I ain't not too sure

Could I please get a help?

Thank you in advance!
  Reply With Quote
09-01-18, 01:25 PM   #2
myrroddin
A Molten Giant
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 950
Assuming you set up your saved variable correctly in OnInitialize, in your enable table, change your get and set functions:
Lua Code:
  1. get = function()
  2.     return self.db.profile.enable
  3. end,
  4. set = function(info, value)
  5.     self.db.profile.enable = value
  6. end
And delete lines 20-22 because that isn't going to work.

Now to disable size based on enable:
Lua Code:
  1. get = function()
  2.     return self.db.profile.size
  3. end,
  4. set = function(info, value)
  5.     self.db.profile.size = value
  6. end,
  7. disabled = function()
  8.     return not self.db.profile.enable
  9. end

Last edited by myrroddin : 09-01-18 at 01:26 PM. Reason: minor typo
  Reply With Quote
09-01-18, 03:33 PM   #3
Lyak
A Cyclonian
Join Date: Jul 2018
Posts: 45
Originally Posted by myrroddin View Post
Assuming you set up your saved variable correctly in OnInitialize, in your enable table, change your get and set functions:
Lua Code:
  1. -- code snippet
And delete lines 20-22 because that isn't going to work.

Now to disable size based on enable:
Lua Code:
  1. -- code snippet
Oh, so the disabled function should be registered within an option that I would like to grey out, not in an enable option?

That makes sense!

One more question tho.

In case if there are more than one option (let's say ten options, maybe), should I register disabled function for all of them via for loop or something?

+ What about child groups?
  Reply With Quote
09-01-18, 04:10 PM   #4
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,557
You can disable options individually or as a whole child group.
https://www.wowace.com/projects/ace3...tables#title-2
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
09-01-18, 08:41 PM   #5
Lyak
A Cyclonian
Join Date: Jul 2018
Posts: 45
Originally Posted by Seerah View Post
You can disable options individually or as a whole child group.
https://www.wowace.com/projects/ace3...tables#title-2
Ah, you are right.

Just needed to put disabled function under the group, not under each individual options.

Thanks, Seerah !!
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » [AceConfig] Grey out options when disabled

Thread Tools
Display Modes

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