VGUI Register

From GMod Wiki

Jump to: navigation, search
Lua: Using VGUI Register
Page white text.png Description:How to make your own VGUI Controls in GMod Lua
User.png Original Author:garry
Calendar.png Created:9th January 2007
vgui.Register allows you to register your own Lua class.
vgui.Register( "MyButton", PANEL, "Button" )

It takes 3 parameters

Once registered you can create an instance of your panel in the normal way, using vgui.Create

local button = vgui.Create( "MyButton" )

Customizing your control

You can add functions to your PANEL table to customize how it behaves.

 PANEL:Paint()
    Overrides paint function for panel.
    Return true to cause it to not draw the default panel

 PANEL::OnMousePressed( mousecode )
 PANEL::OnMouseReleased( mousecode )
   Called when the mouse is pressed/released on the panel.
   Return true to not allow any default actions
 
 PANEL::OnMouseWheeled( delta )
   Called when the mouse is wheeled over the panel
 
 PANEL::OnKeyCodePressed( keycode )
   Called when a key is pressed
   Return true to swallow the key
  
 PANEL:Think()
   Called every frame the panel is visible
 
 PANEL::ApplySchemeSettings( ///todo/// )
   You should use this to apply colours/fonts to your panel and its children

 PANEL::PerformLayout( )
   Use this to position your panel and its children
 
 PANEL::ActionSignal( key, value, ... )
 Receive an ActionSignal (various things are broadcast here)
 
 --------
  Button
 --------

 PANEL::DoClick()
   Called when a the button is clicked
   
---------------
- Member Vars -
---------------
	
 Button
	Selected		-	bool (true if button is selected) 
	Depressed		-	bool (true if button is depressed)
	Armed			-	bool (true if button is hovered)
	DefaultButton	-	bool (true if button is default button)
Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox