From GMod Wiki
Derma Control: DComboBoxItem |
Parent Class: | DLabel |
Subclasses: | |
Description: |
|
Examples
Description | Creates a list of options you can add to it then work with them later. |
Used on | |
Code |
local TestingComboBox = vgui.Create( "DComboBox", FrameParent )
TestingComboBox:SetPos( 10, 35 )
TestingComboBox:SetSize( 100, 185 )
TestingComboBox:SetMultiple( false ) -- Don't use this unless you know extensive knowledge about tables
TestingComboBox:AddItem( "Add" ) -- Add our options
TestingComboBox:AddItem( "Some" )
TestingComboBox:AddItem( "Options" )
TestingComboBox:AddItem( "Here" )
local MainMenuSheet = vgui.Create( "DPanel", FrameParent ) -- We create a panel so we can draw shit on; if we use the frame, it comes up transparent for some reason
MainMenuSheet:SetPos( 125, 50 )
MainMenuSheet:SetSize( DermaFrame:GetWide() - 25, DermaFrame:GetTall() - 25 )
MainMenuSheet.Paint = function()
if TestingComboBox:GetSelectedItems() and TestingComboBox:GetSelectedItems()[1] then -- make sure something is selected if not we get uber spam of errors
local OurStringThing = "Your selection is: "..TestingComboBox:GetSelectedItems()[1]:GetValue().."!" -- This was a pain in the ass to figure out; this gets the name of the option chosen
surface.SetFont( "default" )
surface.SetTextColor( 255, 255, 255, 255 )
surface.SetTextPos( 50, 50 )
surface.DrawText( OurStringThing ) -- Draws the text
end
end
|
Output | N/A |
Methods
DComboBoxItem
DComboBoxItem.ApplySchemeSettings
DComboBoxItem.DoClick
DComboBoxItem.GetMother
DComboBoxItem.GetSelected
DComboBoxItem.Init
DComboBoxItem.OnCursorMoved
DComboBoxItem.OnMousePressed
DComboBoxItem.Paint
DComboBoxItem.PerformLayout
DComboBoxItem.Select
DComboBoxItem.SetMother
DComboBoxItem.SetSelected
Inherited from DLabel
DLabel.OnCursorEntered
DLabel.GetTextColorHovered
DLabel.SetAutoStretchVertical
DLabel.GenerateExample
DLabel.GetColor
DLabel.SetTextColor
DLabel.GetTextColor
DLabel.SetTextColorHovered
DLabel.GetAutoStretchVertical
DLabel.OnCursorExited
DLabel.SetColor