DComboBoxItem

From GMod Wiki

Jump to: navigation, search


Derma Control: DComboBoxItem
Parent Class:DLabel
Subclasses:
Description:

Examples

DescriptionCreates a list of options you can add to it then work with them later.
Used onNewerClient.png
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
 
OutputN/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

NewerClient.png DLabel.OnCursorEntered
NewerClient.png DLabel.GetTextColorHovered
NewerClient.png DLabel.SetAutoStretchVertical
NewerClient.png DLabel.GenerateExample
NewerClient.png DLabel.GetColor
NewerClient.png DLabel.SetTextColor
NewerClient.png DLabel.GetTextColor
NewerClient.png DLabel.SetTextColorHovered
NewerClient.png DLabel.GetAutoStretchVertical
NewerClient.png DLabel.OnCursorExited
NewerClient.png DLabel.SetColor

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox