Garry's Mod Wiki

DBinder

Description

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

Parent

Derives from DButton.

Methods

number DBinder:GetSelectedNumber()
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:OnChange( number iNum )
Called when the player selects a new bind.
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
Output:

Page Links


Special Pages


Wikis

?

Render Time: 34ms

DB GetPage 4
Generate Html 6
SaveChanges (1) 15
Render Body 0
Render Sidebar 6