Panel.SetParent

From GMod Wiki

Jump to: navigation, search
Function
Syntax Panel:SetParent( Panel parent )
Description:
Sets the parent of the panel. The panel will move relative to it's parent.
Returns: nil
In Object: Panel
Realm: NewerClient.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=Panel.SetParent]Panel.SetParent [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]




Examples

Descriptionsets the parent of the panel
Used onNewerClient.png
Code
 
function startframe() // the frame it will be set in.
   local start1 = vgui.Create( "DFrame" ); // sets start1 to vgui create it makes it alot easier then typing it over and over so this will help.
   start1:SetPos(100,100); // position of the frame
   start1:SetSize(200,200); // size of the frame
   start1:SetTitle("Changeteam"); // title on top in this case Change Team
   start1:MakePopup(); // will show the frame (not needed should already be set by default)
   start1:SetVisible(true); // same as ^
   start1:ShowCloseButton(true); // shows the X on top right or left
   start1:SetDraggable(true); // can move the frame around
 
   local start2 = vgui.Create( "DButton", startframe ); // sets a button (button , ((asigns it to startframe aka the frame above us ^))
 start2:SetParent( start1 );'' // it will be asigned with start1 as Vgui.create ("DFrame");
   start2:SetText( "Light" ); // text of frame in this case Light
   start2:SetPos( 25, 50 ); // pos of button
   start2:SetSize( 150, 50 ); // size of button
   start2.DoClick = function() // on click will run what you asign it to
      RunConsoleCommand( "kill" ) // in this case kill
   		end 
	end
end
OutputN/A


Additional Notes

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox