Garry's Mod Wiki

CtrlNumPad

Description

CtrlNumPad is a VGUI element designed primarily for SpawnMenu and ControlPanel. It is used to create a DBinder with at least one DLabel. Each change made by the player in the CtrlNumPad acts on a previously defined ConVar.

To retrieve the panels associated with the vgui :

  • To retrieve the DBinder created, you can use this variable associated with the panel : PANEL.NumPad1
  • To retrieve the first DLabel created, you can use this variable associated with the panel : PANEL.Label1
  • To retrieve the second DLabel created, you can use this variable associated with the panel : PANEL.Label2

By default, the DLabel:SetDark function is activated on both DLabels.

To retrieve the value of the CtrlNumPad you can use this function: Player:GetInfoNum

View source

Parent

Derives methods, etc not listed on this page from CtrlNumPad.

Methods

CtrlNumPad:SetConVar1( string cvar )
The name of the convar that will store the key code for player selected key of the left key binder.
CtrlNumPad:SetConVar2( string cvar )
If set and label2 is set, the name of the convar that will store the key code for player selected key of the right key binder.
CtrlNumPad:SetLabel1( string txt )
The label for the left key binder.
CtrlNumPad:SetLabel2( string txt )
If set and convar2 is set, the label for the right key binder.

Example

Example of a spawnmenu use case

hook.Add( "PopulateToolMenu", "TestPopulateToolMenu", function() spawnmenu.AddToolMenuOption( "Create Category", "Other", "category_example", "#Create Name", "", "", function( panel ) panel:ClearControls() panel:KeyBinder("Test", "convartest") end ) end)
Output:
image.png