rendered paste body// Command button
local Panel = { }
function Panel:Init( )
self.Text = "x"
self.Alpha = 0
self.BackColor = { 153, 204, 255 }
self.ForeColor = { 0, 0, 0 }
self.CallBack = function( ) end
self:SetMouseInputEnabled( true )
end
function Panel:Paint( )
local w, h = self:GetWide( ), self:GetTall( )
// Draw button
surface.SetDrawColor( self.BackColor[ 1 ], self.BackColor[ 2 ], self.BackColor[ 3 ], self.Alpha )
surface.DrawRect( 0, 0, w, h )
// Text
surface.SetTextColor( self.ForeColor[ 1 ], self.ForeColor[ 2 ], self.ForeColor[ 3 ], self.Alpha )
surface.SetFont( "Default" )
local tx, ty = surface.GetTextSize( self.Text )
surface.SetTextPos( w / 2 - tx / 2, h / 2 - ty / 2 )
surface.DrawText( self.Text )
return true
end
function Panel:DoClick( x, y )
self.CallBack( )
end
vgui.Register( "etc_Command_Button", Panel, "Button" )