I am currently working on my very first WoW Addon. I taught lua myself with the help of some youtube videos by Mayron. In EP 6 and EP 7 he started with Widgets and XML files. Everything worked perfectly, except the Checkboxes. They work and look fine, but the text is on the box an not right oft it. In his video it looks perfect, but not when i do it.
This is his Code:
local UIConfig = CreateFrame("Frame", "MUI_BuffFrame", UIParent, "BasicFrameTemplateWithInset");
UIConfig:SetSize(260, 360);
UIConfig:SetPoint("CENTER"); -- Doesn't need to be ("CENTER", UIParent, "CENTER")
UIConfig.title = UIConfig:CreateFontString(nil, "OVERLAY", "GameFontHighlight");
UIConfig.title:SetPoint("LEFT", UIConfig.TitleBg, "LEFT", 5, 0);
UIConfig.title:SetText("MUI Buff Option");
---------------------------------
-- Buttons
---------------------------------
-- Save Button:
UIConfig.saveBtn = CreateFrame("Button", nil, UIConfig, "GameMenuButtonTemplate");
UIConfig.saveBtn:SetPoint("CENTER", UIConfig, "TOP", 0, -70);
UIConfig.saveBtn:SetSize(140, 40);
UIConfig.saveBtn:SetText("Save");
UIConfig.saveBtn:SetNormalFontObject("GameFontNormalLarge");
UIConfig.saveBtn:SetHighlightFontObject("GameFontHighlightLarge");
-- Reset Button:
UIConfig.resetBtn = CreateFrame("Button", nil, UIConfig, "GameMenuButtonTemplate");
UIConfig.resetBtn:SetPoint("TOP", UIConfig.saveBtn, "BOTTOM", 0, -10);
UIConfig.resetBtn:SetSize(140, 40);
UIConfig.resetBtn:SetText("Reset");
UIConfig.resetBtn:SetNormalFontObject("GameFontNormalLarge");
UIConfig.resetBtn:SetHighlightFontObject("GameFontHighlightLarge");
-- Load Button:
UIConfig.loadBtn = CreateFrame("Button", nil, UIConfig, "GameMenuButtonTemplate");
UIConfig.loadBtn:SetPoint("TOP", UIConfig.resetBtn, "BOTTOM", 0, -10);
UIConfig.loadBtn:SetSize(140, 40);
UIConfig.loadBtn:SetText("Load");
UIConfig.loadBtn:SetNormalFontObject("GameFontNormalLarge");
UIConfig.loadBtn:SetHighlightFontObject("GameFontHighlightLarge");
---------------------------------
-- Sliders
---------------------------------
-- Slider 1:
UIConfig.slider1 = CreateFrame("SLIDER", nil, UIConfig, "OptionsSliderTemplate");
UIConfig.slider1:SetPoint("TOP", UIConfig.loadBtn, "BOTTOM", 0, -20);
UIConfig.slider1:SetMinMaxValues(1, 100);
UIConfig.slider1:SetValue(50);
UIConfig.slider1:SetValueStep(30);
UIConfig.slider1:SetObeyStepOnDrag(true);
-- Slider 2:
UIConfig.slider2 = CreateFrame("SLIDER", nil, UIConfig, "OptionsSliderTemplate");
UIConfig.slider2:SetPoint("TOP", UIConfig.slider1, "BOTTOM", 0, -20);
UIConfig.slider2:SetMinMaxValues(1, 100);
UIConfig.slider2:SetValue(40);
UIConfig.slider2:SetValueStep(30);
UIConfig.slider2:SetObeyStepOnDrag(true);
---------------------------------
-- Check Buttons
---------------------------------
-- Check Button 1:
UIConfig.checkBtn1 = CreateFrame("CheckButton", nil, UIConfig, "UICheckButtonTemplate");
UIConfig.checkBtn1:SetPoint("TOPLEFT", UIConfig.slider1, "BOTTOMLEFT", -10, -40);
UIConfig.checkBtn1.text:SetText("My Check Button!");
now, if i put this exact code into my addon it tells me “attempt to index field ‘text’ (a nil value)” in the line of
UIConfig.checkBtn1.text:SetText("My Check Button!");
i can see the checkbox at its position, but no text.
now i tried to change this line of code to:
UIConfig.checkBtn1:SetText("My Check Button!");
then there is also no text at all, but also no error code.
then i gave the text a font:
UIConfig.checkBtn1:SetText("My Check Button!");
UIConfig.checkBtn1:SetNormalFontObject("GameFontNormal");
now i can see the text, but it is centered on the checkbox, so when it is checked i can’t read the text.
Is there any way to reposition the text of the checkbox? Or can anyone tell me, why the initial code isn’t working for me?