WoWInterface - View Single Post - adding a GUI for addon options
View Single Post
06-01-10, 01:11 PM   #10
nUI Maintainer
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,511
Where is the UI code for the check box ?

This is roughly what I do to get checkboxes to work:

--Create the Button
local f = CreateFrame("CheckButton", name, parent,"OptionsCheckButtonTemplate")
local f.Text = _G[f:GetName().."Text"]

-- initialise a dirty flag for a global update run
parent.dirty = false

-- Get Current Value for this CheckBox from the saved variables table

-- Now we can tell it to react to any further changes
   local checked = ( self:GetChecked() == 1 )
   -- It needs to be stored in a stored variable somewhere
   MySavedVariablesTable[name] = MySavedVariablesTable[name] or {}
   MySavedVariablesTable[name]["isChecked"] = checked

   -- Update addon to reflect this change only
   if ( checked ) then 
      -- Do something because this is checked
      -- Do something else because it isn't checked

   -- Or flag that a change has been made for a global update later
   parent.dirty = true
If you use the dirty option set up a button to *Confirm* the changes and then call an UpdateRoutine if there have been changes ( settings are dirty ).

Edit: Note though that the Saved Variables Table doesn't have to be set up this way to work. As long as the value that is stored in the saved variables is set and used and the OnClick script set and acted on then it should work as descirbed.

Last edited by Xrystal : 06-01-10 at 01:14 PM.
  Reply With Quote