Garry's Mod Wiki

DBinder

Description

Input which can bind a command to a key. Used for binding inputs and outputs of TOOLs.

View source

Parent

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

Events

DBinder:OnChange( number iNum )
Called when the player selects a new bind.

Methods

Gets the code of the key currently bound by the DBinder. Same as DBinder:GetValue.
number DBinder:GetValue()
Gets the code of the key currently bound by the DBinder. Same as DBinder:GetSelectedNumber.
DBinder:SetSelectedNumber( number keyCode )
Sets the current key bound by the DBinder, and updates the button's text as well as the ConVar.
DBinder:SetValue( number keyCode )
Alias of DBinder:SetSelectedNumber.
DBinder:UpdateText()
This is used internally - although you're able to use it you probably shouldn't. Used to set the text of the DBinder to the current key binding, or NONE.

Example

Creates a DBinder that prints to the player's chat when a new key is bound.

local frame = vgui.Create("DFrame") frame:SetSize(250,100) frame:Center() frame:SetTitle("DBinder Example") frame:MakePopup() local binder = vgui.Create( "DBinder", frame ) binder:SetSize( 200, 50 ) binder:SetPos( 25, 35 ) function binder:OnChange( num ) LocalPlayer():ChatPrint("New bound key: "..input.GetKeyName( num )) end
DBinder.gif