I think, I explained my problem not good enough, and I still require a bit of your help please. I spend lots of hours learning lua and trying to figure out everything by my self, but no luck, just lots of lua errors.
I got this xml code:
Code:
<Frame name="MyFrame" hidden="true" parent="InterfaceOptionsFramePanelContainer">
<CheckButton name="$parentCheckBoxOne" inherits="InterfaceOptionsCheckButtonTemplate">
<Anchors>
<Anchor>
</Anchor>
</Anchors>
<Scripts>
<OnLoad>
self:RegisterEvent("PLAYER_ENTERING_WORLD")
self.panel = "GROUPS_AND_RAID_FINDER"
self.name = "ParentCheckBox"
self.root = true
</OnLoad>
<OnEvent>
self:UnregisterEvent("PLAYER_ENTERING_WORLD")
SetMyOptionsButtons(self)
</OnEvent>
<OnClick>
ToggleMyOptions(self)
</OnClick>
</Scripts>
</CheckButton>
<CheckButton name="$parentCheckBoxTwo" inherits="InterfaceOptionsSmallCheckButtonTemplate">
<Anchors>
<Anchor>
</Anchor>
</Anchors>
<Scripts>
<OnLoad>
self:RegisterEvent("PLAYER_ENTERING_WORLD")
self.variable = "variable"
self.name = "ChildCheckBox"
self.parent = "ParentCheckBox"
</OnLoad>
<OnEvent>
self:UnregisterEvent("PLAYER_ENTERING_WORLD")
SetMyOptionsButtons(self)
</OnEvent>
<OnClick>
ToggleMyOptions(self)
</OnClick>
</Scripts>
</CheckButton>
</Frame>
I got global variables ParentCheckBox = true/false and ChildCheckBox = true/false
A want to control second one (Disable/Enable) if first one is on or off. And i would like to make it for lots of checkboxes, so i don't want to hardcode every single checkbox.
function SetMyOptionsButtons(self) - this function on event check if self.name == true - then checkbox is checked, else it's unchecked, plus it checks if self.parent not nil and if it isn't then this function disable button if self.parent == false
function ToggleMyOptions(self) - just set self.name to true or false.
First i thought that i can somehow fire some Blizzard events, for example every time i toggle checkbox with self.root == true it fires event (cvar) and then register this event for ChildCheckBox. But i think it's not the right way to trigger cvar.
I search Blizard code, and found this function, but can't figure out how to implement it in to my case.
Lua Code:
function BlizzardOptionsPanel_SetupDependentControl (dependency, control)
if ( not dependency ) then
return;
end
assert(control);
dependency.dependentControls = dependency.dependentControls or {};
tinsert(dependency.dependentControls, control);
if ( control.type ~= CONTROLTYPE_DROPDOWN ) then
control.Disable = function (self) getmetatable(self).__index.Disable(self) _G[self:GetName().."Text"]:SetTextColor(GRAY_FONT_COLOR.r, GRAY_FONT_COLOR.g, GRAY_FONT_COLOR.b) end;
control.Enable = function (self) getmetatable(self).__index.Enable(self) _G[self:GetName().."Text"]:SetTextColor(HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b) end;
else
control.Disable = function (self) UIDropDownMenu_DisableDropDown(self) end;
control.Enable = function (self) UIDropDownMenu_EnableDropDown(self) end;
end
end
Conclusion:
I thought maybe it's possible somehow to trigger ChildCheckBox SetMyOptionsButtons(self) function every time i click (toggle) ParentCheckBox? If it's possible could your please help me with a little example or a few lines of code.
Edit:
Changed SetAdvancedInterfaceOptionsButtons(self) to SetMyOptionsButtons(self)