Category:DComboBox

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
m
m (panel is not passed)
Line 14: Line 14:
 
DComboBox:AddChoice( "option B" )
 
DComboBox:AddChoice( "option B" )
 
DComboBox:AddChoice( "option C" )
 
DComboBox:AddChoice( "option C" )
DComboBox.OnSelect = function( panel, index, value )
+
DComboBox.OnSelect = function( index, value )
 
print( value .." was selected!" )
 
print( value .." was selected!" )
 
end
 
end
Line 30: Line 30:
 
comboBox:SetValue("All Players")
 
comboBox:SetValue("All Players")
  
comboBox.OnSelect = function(_, _, value)
+
comboBox.OnSelect = function(_, value)
 
print(value.." was selected!")
 
print(value.." was selected!")
 
end
 
end

Revision as of 19:01, 9 January 2019

Contents

DescriptionPanelPage

A field with multiple selectable values.

Inherited Functions

Inherits the following functions from DButton and its parents up to 3 levels deep:


Examples

Example

Creates a Combo Box.

local DComboBox = vgui.Create( "DComboBox" )
DComboBox:SetPos( 5, 5 )
DComboBox:SetSize( 100, 20 )
DComboBox:SetValue( "options" )
DComboBox:AddChoice( "option A" )
DComboBox:AddChoice( "option B" )
DComboBox:AddChoice( "option C" )
DComboBox.OnSelect = function( index, value )
	print( value .." was selected!" )
end

Output:


PictureA.png DComboBox2.png DComboBox3.png

option B was selected!

Examples

Example

Create a Combo Box with all players

local comboBox = vgui.Create("DComboBox")
comboBox:SetPos(5, 5)
comboBox:SetSize(100, 20)
comboBox:SetValue("All Players")

comboBox.OnSelect = function(_, value)
	print(value.." was selected!")
end

for k,v in pairs(player.GetAll()) do
	comboBox:AddChoice(v:Name())
end

Output:


DComboBoxAllPlayers.png

Bot01 was selected!
Personal tools
Navigation