DPropertySheet/CloseTab

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
(Added example of Usage.)
Line 17: Line 17:
 
|type=Panel
 
|type=Panel
 
|desc=The panel of the tab.
 
|desc=The panel of the tab.
 +
}}
 +
{{Example
 +
|Description=Example of how you'd create and use this panel and close unnecessary sheets.
 +
|Code=local MainFrame = vgui.Create( "DFrame" )
 +
MainFrame:SetSize( 500, 300 )
 +
MainFrame:Center()
 +
MainFrame:MakePopup()
 +
 +
local MainSheet = vgui.Create( "DPropertySheet", MainFrame )
 +
MainSheet:Dock( FILL )
 +
 +
local First_Panel = vgui.Create( "DPanel", MainSheet )
 +
First_Panel.Paint = function( self, w, h ) draw.RoundedBox( 4, 0, 0, w, h, Color( 255, 128, 0, self:GetAlpha() ) ) end
 +
 +
MainSheet:AddSheet( "Users Page", First_Panel, "icon16/user.png" )
 +
local Second_Panel = vgui.Create( "DPanel", MainSheet )
 +
Second_Panel.Paint = function( self, w, h ) draw.RoundedBox( 4, 0, 0, w, h, Color( 0, 128, 255, self:GetAlpha() ) ) end
 +
MainSheet:AddSheet( "Admins Page", Second_Panel, "icon16/lightning.png" )
 +
 +
if LocalPlayer():IsAdmin() then
 +
MainSheet:CloseTab( MainSheet:GetItems()[1].Tab ) --1 is a representation of the first sheet
 +
else
 +
MainSheet:CloseTab( MainSheet:GetItems()[2].Tab ) --2 is a representation of the second sheet
 +
end
 
}}
 
}}

Revision as of 09:01, 8 September 2019

 DPropertySheet:CloseTab( )

Contents

DescriptionPanelFunc

Removes tab and/or panel from the parent DPropertySheet.

Arguments

Panel tab

The DTab of the sheet from DPropertySheet.

See DPropertySheet:GetItems.

Arguments

boolean removePanel

Set to true to remove the associated panel object as well.

Returns

Panel

The panel of the tab.

Examples

Example

Example of how you'd create and use this panel and close unnecessary sheets.

local MainFrame = vgui.Create( "DFrame" )
MainFrame:SetSize( 500, 300 )
MainFrame:Center()
MainFrame:MakePopup()

local MainSheet = vgui.Create( "DPropertySheet", MainFrame )
MainSheet:Dock( FILL )

local First_Panel = vgui.Create( "DPanel", MainSheet )
First_Panel.Paint = function( self, w, h ) draw.RoundedBox( 4, 0, 0, w, h, Color( 255, 128, 0, self:GetAlpha() ) ) end

MainSheet:AddSheet( "Users Page", First_Panel, "icon16/user.png" )
local Second_Panel = vgui.Create( "DPanel", MainSheet )
Second_Panel.Paint = function( self, w, h ) draw.RoundedBox( 4, 0, 0, w, h, Color( 0, 128, 255, self:GetAlpha() ) ) end
MainSheet:AddSheet( "Admins Page", Second_Panel, "icon16/lightning.png" )

if LocalPlayer():IsAdmin() then
	MainSheet:CloseTab( MainSheet:GetItems()[1].Tab ) --1 is a representation of the first sheet
else
	MainSheet:CloseTab( MainSheet:GetItems()[2].Tab ) --2 is a representation of the second sheet
end


Personal tools
Navigation