Thread Tools Display Modes
10/22/14, 03:41 PM   #1
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
LibAddonMenu CheckBox

In a LibAddonMenu checkbox is there a function to get a true/false value to see if it is checked or not without grabbing the checkbox:GetText() and comparing it to controls checktedText to see if they match? Its a value I didn't want to save. I just wanted to read it when the user presses a button while the panel is still open and then I don't need it anymore.

I looked through the LibAddonMenu code but it looks like all it does is toggle the SetText(..) unless I'm missing something.

Edit:
While I'm at it, since LibAddonMenu controls aren't created until the panel is open is there a way to know when the controls are created so you can change the CheckedText/UncheckedText ?

Last edited by circonian : 10/22/14 at 03:47 PM.
  Reply With Quote
10/22/14, 06:17 PM   #2
merlight
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 671
Originally Posted by circonian View Post
In a LibAddonMenu checkbox is there a function to get a true/false value to see if it is checked or not without grabbing the checkbox:GetText() and comparing it to controls checktedText to see if they match? Its a value I didn't want to save. I just wanted to read it when the user presses a button while the panel is still open and then I don't need it anymore.
You can provide getFunc/setFunc handlers that will tie checkbox status to a variable.

Lua Code:
  1. local g_checked = false
  2.  
  3. local checkboxData = {
  4.    ...
  5.    getFunc = function() return g_checked end,
  6.    setFunc = function(value) g_checked = value end,
  7. }

Originally Posted by circonian View Post
While I'm at it, since LibAddonMenu controls aren't created until the panel is open is there a way to know when the controls are created so you can change the CheckedText/UncheckedText ?
Lua Code:
  1. -- hope it's correct syntax
  2. CALLBACK_MANAGER:RegisterCallback("LAM-PanelControlsCreated", handler)
  Reply With Quote
10/22/14, 07:06 PM   #3
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 648
Originally Posted by circonian View Post
In a LibAddonMenu checkbox is there a function to get a true/false value to see if it is checked or not without grabbing the checkbox:GetText() and comparing it to controls checktedText to see if they match? Its a value I didn't want to save. I just wanted to read it when the user presses a button while the panel is still open and then I don't need it anymore.

I looked through the LibAddonMenu code but it looks like all it does is toggle the SetText(..) unless I'm missing something.
I don't know what you mean by this "when the user presses a button while the panel is still open". If what merlight provided you with is not what you are looking for, then no. There is no GetValue method, as settings are usually supposed to be saved to a saved variable. Even if you don't want to save the value to your saved variables file, you should still save it to *some* variable if you want to access it later.

Edit:
While I'm at it, since LibAddonMenu controls aren't created until the panel is open is there a way to know when the controls are created so you can change the CheckedText/UncheckedText ?
Yes, register for the "LAM-PanelControlsCreated" callback, which merlight also provided above. The arg passed through is the panel whose controls are now available.
  Reply With Quote
10/22/14, 10:09 PM   #4
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
Originally Posted by Seerah View Post
I don't know what you mean by this "when the user presses a button while the panel is still open". Even if you don't want to save the value to your saved variables file, you should still save it to *some* variable if you want to access it later.
Yeah, what I was trying probably wasn't the best way to do it. I am saving them I just didn't want the user to have access to any of it via the controls. I was trying to reuse the controls (to avoid creating a lot of duplicate settings controls) to allow them to select different groups of settings & click a button to save them. Plus once saved I didn't want them to be able to change the settings (so I didn't want the controls linked directly to the saved variables). They can only delete their preference (group of settings) and create a new one.

I realize I could just make a dummy variable for every control I have, attach the getFunc()'s & setFunc()'s to them to temporarily hold the value, read the value from the savedVariables, copy them all to my table, then reset all the controls back to the default value so they can save another group of options. I just figured since I didn't want the controls to linked to the savedVariables & I'm resetting the controls back to default everytime anyhow, I was just looking for a way to avoid using the getFunc()'s, setFunc()'s and all of those extra dummy savedVariables that would temporarily hold the values.


Thanks for your help, both of you.
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » LibAddonMenu CheckBox

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