Soo das hier hab ich aus deiner Vorlage gemacht, soweit gibt es keine Fehlermeldungen mehr beim anklicken, jedoch werden auch keine Checkboxen angezeigt
Lua Code:
Options_Child:SetScript("OnShow",
function(self)
PlaySound("igMainMenuOptionCheckBoxOn" or "igMainmenuOptionCheckBoxOff")
--checkboxes begin
local expansion = Options_Child.name
print(expansion.." clicked")
--wenn noch keine checkboxen vorhanden dann erstmal erstellen
if not self.herbCheckboxes then
self.herbCheckboxes = {}
--alle kräuter der jeweiligen untertabelle durchgehen und jeweils eine checkbox erstellen
for itemID, optionValue in pairs(MillButton_Herblist[expansion]) do
--name des krauts für das label der checkbox holen
local itemName = GetItemInfo(itemID)
--ankerpunkt für die erste checkbox
local tAnchorPointY = -10
--checkbox erstellen (siehe helper function unten) und für späteren zugriff referenz auf checkbox-objekt mit itemid vom kraut als index in herbCheckboxes speichern
self.herbCheckboxes[itemID] = Addon:CreateOptionsCheckButton(self, itemName)
--passend anordnen
self.herbCheckboxes[itemID]:SetPoint("TOPLEFT", self.parent, "TOPLEFT", 10, tAnchorPointY)
--ankerpunkt für die nächste checkbox
tAnchorPointY = tAnchorPointY - self.herbCheckboxes[itemID]:GetHeight()
end
end
--alle inhalte self.herbCheckboxes durchgehen und den aktuellen wert (checked/nicht checked bzw. true/false) für die checkbox entsprechend der db festlegen
for itemID, checkboxObj in pairs(self.herbCheckboxes) do
--wert der checkbox entsprechend der tabelle festlegen
checkboxObj:SetChecked(MillButton_Herblist[expansion][itemID])
--bei wertänderung in der db speichern
checkboxObj:SetScript("OnClick", function()
MillButton_Herblist[self:GetParent().name][self.itemID] = self:GetChecked()
end)
end
--checkboxes end
end)
end
Options:SetScript("OnShow", nil)
end)
SLASH_MILLBUTTON1 = "/millbutton"
SLASH_MILLBUTTON2 = "/mbtn"
SlashCmdList.MILLBUTTON = function() InterfaceOptionsFrame_OpenToCategory(Options) end
-- Checkbox HELPERS Beginn
function Addon:CreateOptionsCheckButton(pParentFrame, pLabelText)
local tCheckBoxFrame = CreateFrame("CheckButton", nil, pParentFrame)
tCheckBoxFrame:SetWidth(25)
tCheckBoxFrame:SetHeight(25)
tCheckBoxFrame:SetNormalTexture("Interface\\Buttons\\UI-CheckBox-Up")
tCheckBoxFrame:SetPushedTexture("Interface\\Buttons\\UI-CheckBox-Down")
tCheckBoxFrame:SetHighlightTexture("Interface\\Buttons\\UI-CheckBox-Highlight")
tCheckBoxFrame:SetCheckedTexture("Interface\\Buttons\\UI-CheckBox-Check")
tCheckBoxFrame:SetDisabledCheckedTexture("Interface\\Buttons\\UI-CheckBox-Check-Disabled")
tCheckBoxFrame:SetFrameStrata("HIGH")
tCheckBoxFrame:Show()
local tFS = tCheckBoxFrame:CreateFontString(nil, "OVERLAY")
tCheckBoxFrame.fontstring = tFS
tFS:SetFont("Fonts\\ARIALN.TTF", 12)
tFS:SetFontObject(GameFontNormalSmall)
tFS:SetText(pLabelText)
tFS:SetTextColor(1, 1, 1, 1)
tFS:SetJustifyH("LEFT")
tFS:SetJustifyV("TOP")
tFS:SetPoint("LEFT", tCheckBoxFrame, "RIGHT", 0, 0)
tFS:Show()
return tCheckBoxFrame
end
-- Checkbox HELPERS Ende
Ich hab mich da bestimmt irgendwo "verlaufen"...
/letztes edit für heute:
jetzt bekomm ich die Checkboxen zwar angezeigt aber die hängen alle auf einander..
das hier hab ich geändert, also aus self.parent wurde SubOptionPanel:
Lua Code:
self.herbCheckboxes[itemID]:SetPoint("TOPLEFT", SubOptionPanel, "TOPLEFT", 10, tAnchorPointY)
--ankerpunkt für die nächste checkbox
tAnchorPointY = tAnchorPointY - self.herbCheckboxes[itemID]:GetHeight()