Garry's Mod Wiki

Panel:SetEnabled

  Panel:SetEnabled( boolean enable )

Description

Sets the enabled state of a panel object that supports being disabled, such as a DButton or DTextEntry.

Disabled panels cannot be interacted with, and have a different appearance to indicate this.

See Panel:IsEnabled for a function that retrieves the "enabled" state of a panel.

Arguments

1 boolean enable
Whether to enable or disable the panel object.

Example

Crates a panel that is enabled and a panel that is disabled.

local frame = vgui.Create( "DFrame" ) frame:SetSize( 300, 250 ) frame:Center() frame:MakePopup() local DermaButton = vgui.Create( "DButton", frame ) DermaButton:SetText( "Say hi" ) DermaButton:SetPos( 25, 50 ) DermaButton:SetSize( 250, 30 ) DermaButton.DoClick = function() RunConsoleCommand( "say", "Hi" ) end -- This panel is disabled, so the button won't be clickable local DisabledButton = vgui.Create( "DButton", frame ) DisabledButton:SetText( "Can't touch me" ) DisabledButton:SetEnabled( false ) DisabledButton:SetPos( 25, 100 ) DisabledButton:SetSize( 250, 30 ) DisabledButton.DoClick = function() RunConsoleCommand( "say", "This will never show up" ) end
Output:
image.png