Thread Tools Display Modes
02-18-08, 07:48 PM   #1
Zilver
A Fallenroot Satyr
 
Zilver's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2006
Posts: 29
CheckButton inside a Tabbed Frame... HOW?

Here is part on my code, my problem is that i have trouble getting the CheckButton to function within my TabbedFrame, I hope that some 1 might be able to help me overcome this barrier.

XML:
Code:
<Frame name="MenuFrame" toplevel="true" frameStrata="DIALOG" movable="true" enableMouse="true" hidden="true" parent="UIParent">
	<Size>
	<Anchors>
	<Backdrop>
	<Layers>
		<Layer level="ARTWORK">
			<Texture name="FrameHeader" file="Interface\DialogFrame\UI-DialogBox-Header">
				<Size>
				<Anchors>
			</Texture>
			<FontString inherits="GameFontNormal" text="Menu">
				<Anchors>
			</FontString>
		</Layer>
	</Layers>
	<Frames>
		<Button name="CloseButton">
			<Size>
			<Anchors>
		</Button>
		<Frame name="TabPage1" hidden="false">
			<Anchors>
			<Layers>
				<Layer level="ARTWORK">
					<FontString inherits="GameFontNormal" text="General Options">
						<Anchors>
					</FontString>
				</Layer>
			</Layers>
			<Frames>
				<CheckButton name="ToggleButton" inherits="OptionsCheckButtonTemplate">
					<Anchors>
					<Scripts>
						<OnLoad>
							getglobal(this:GetName().."Text"):SetText("Enable Button");
						</OnLoad>
						<OnClick>
							Toggle();
						</OnClick>
					</Scripts>
				</CheckButton>
			</Frames>
		</Frame>
		<Button name="$parentTab1" inherits="CharacterFrameTabButtonTemplate" id="1" text="General">
			<Anchors>
				<Anchor point="CENTER" relativePoint="BOTTOMLEFT">
					<Offset>
						<AbsDimension x="60" y="-8"/>
					</Offset>
				</Anchor>
			</Anchors>
			<Scripts>
				<OnClick>
					PanelTemplates_SetTab(MenuFrame, 1);
					TabPage1:Show();
					TabPage2:Hide();
					TabPage3:Hide();
					TabPage4:Hide();
				</OnClick>
			</Scripts>
		</Button>
	</Frames>
	<Scripts>
		<OnLoad>
			this.elapsed = 0;
			PanelTemplates_SetNumTabs(MenuFrame, 4);
			PanelTemplates_SetTab(MenuFrame, 1);
		</OnLoad>
		<OnShow>
			PlaySound("UChatScrollButton");
			PanelTemplates_SetTab(MenuFrame, 1);
			TabPage1:Show();
			myTabPage2:Hide();
			myTabPage3:Hide();
			myTabPage4:Hide();
		</OnShow>
		<OnHide>
			PlaySound("UChatScrollButton");
		</OnHide>
		<OnMouseDown>
			if(arg1 == "LeftButton") then
				this:StartMoving();
			end					
		</OnMouseDown>
		<OnMouseUp>
			if(arg1 == "LeftButton") then
				this:StopMovingOrSizing();
			end
		</OnMouseUp>
	</Scripts>
</Frame>
LUA:
Code:
MyVariable = "true";

function OnLoad()
	this:RegisterEvent("VARIABLES_LOADED");
	PanelTemplates_SetNumTabs(MenuFrame, 4);
	PanelTemplates_SetTab(MenuFrame, 1);
	TabPage1:Show();
	TabPage2:Hide();
	TabPage3:Hide();
	TabPage4:Show();
end

function Event(event)
	if (event == "PLAYER_ENTERING_WORLD") then
			MenuFrame:Hide();
			return;
			
	elseif (event == "VARIABLES_LOADED") then
		Menu_Vars();
	end
end

function Menu_Vars()
	ToggleButton:SetChecked(MyVariable);
end

function Toggle()
	if(MyVariable == "true") then
		MyVariable = "false";
		ToggleButton:SetChecked(MyVariable);
	else
		MyVariable = "true";
		ToggleButton:SetChecked(MyVariable);
		A_Frame:Show();
	end
end
As I understand from the guides and notes on wowwiki.com this should work, some 1 see anything I have missed? Any help would be apprisiated...
  Reply With Quote
02-19-08, 06:09 AM   #2
Layrajha
A Frostmaul Preserver
 
Layrajha's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 275
If the XML code here is your whole XML code, then it's not correct. I mean, not talking about what check button is in what tab, I haven't really checked that, but the XML syntax is bad, because many tags (such as <Anchors> or <Size>) are opened here and there and never closed.

You should try a XML tutorial (I think there's a tutorial-links section on this forum), go slowly, check other addons (for instance Blizzard's XML files that can be downloaded on the US site's technical support page); and whenever you have something that doesn't work, remove the last thing you've added, and put things back piece by piece to see what didn't work and learn why it didn't work.
  Reply With Quote
02-19-08, 10:03 AM   #3
Zilver
A Fallenroot Satyr
 
Zilver's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2006
Posts: 29
It's not the entire code... had to make like 510 lines of code into something ppl could actually read ... I have a fulle working menu, but trying to implement the Tab's into the code and my code break up totally .... I have made a Tabbed Frame that work, but once i try to put the CheckButton's inside the code, clicking it will result in a error ... [string \"ToggleButton:OnClick\"]:1: attempt to call global 'TabPage4_Toggle' (a nil value)", .... and I do get a Savedvariable file, but the options is not checked inside the Menu... hope this made things a little more clear what the problem is.
  Reply With Quote
02-19-08, 12:50 PM   #4
Zilver
A Fallenroot Satyr
 
Zilver's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2006
Posts: 29
have some how corrected the error, now I only need the checkbutton to reconise my Savedvariable as a state ...
the states depending on button press:

Variable = "true"
Variable = "false"

Onload my checkbutton dosn't show the current state of the Variable, in other words the checkbutton always is unchecked after load ....

So my problem is:
checkbutton:SetChecked(Variable);

while trying this ingame via the chat:

/script checkbutton:SetChecked(Variable);

or

/script checkbutton:SetChecked(true);

even if i do:

/script checkbutton:SetChecked(1);

I get this error:

[string "getglobal(MyTabPage1_MinimapButtonToggleBut..."] line 1:
attempt to index a nil value

so any 1 know anything about doing checkbutton:SetChecked(true)?

Last edited by Zilver : 02-19-08 at 02:14 PM.
  Reply With Quote
02-19-08, 08:37 PM   #5
Zilver
A Fallenroot Satyr
 
Zilver's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2006
Posts: 29
OK so here it is .... the "VALUE" you need to pass to a CheckButton need to be:
Variable = true;
or
Variable = false;

the main thing to notis is that there can't be "" around the variable.... like this
Variable = "false"; ---> this will result in a error.

PLEASE CLOSE THIS THREAD
SOLUTION HAVE BEEN FOUND.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » CheckButton inside a Tabbed Frame... HOW?


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