I was trying to program something when I came over this:
[CODE]
local DComboBox = vgui.Create( "DComboBox", Panel )
DComboBox:SetPos( 20, 43 )
DComboBox:SetSize( 350, 20 )
DComboBox:SetValue( "Choose a Option" )
DComboBox:AddChoice( "C" )
DComboBox:AddChoice( "B" )
DComboBox:AddChoice( "A" )
DComboBox.OnSelect = function( panel, index, value )
print( value .." was selected!" )
end
[/CODE]
[IMG]http://i.imgur.com/3r8RlNc.jpg?1[/IMG]
It automaticly sorts the code alphabetical. Any method you can bypass this with? I been searching around without getting any answears.
Any help is appreciated. :)
If you look at the source code of DComboBox you'll find this:
[lua]
--[[---------------------------------------------------------
Name: OpenMenu
-----------------------------------------------------------]]
function PANEL:OpenMenu( pControlOpener )
if ( pControlOpener ) then
if ( pControlOpener == self.TextEntry ) then
return
end
end
-- Don't do anything if there aren't any options..
if ( #self.Choices == 0 ) then return end
-- If the menu still exists and hasn't been deleted
-- then just close it and don't open a new one.
if ( IsValid( self.Menu ) ) then
self.Menu:Remove()
self.Menu = nil
end
self.Menu = DermaMenu()
local sorted = {}
for k, v in pairs( self.Choices ) do table.insert( sorted, { id = k, data = v } ) end
for k, v in SortedPairsByMemberValue( sorted, "data" ) do
self.Menu:AddOption( v.data, function() self:ChooseOption( v.data, v.id ) end )
end
local x, y = self:LocalToScreen( 0, self:GetTall() )
self.Menu:SetMinimumWidth( self:GetWide() )
self.Menu:Open( x, y, false, self )
end
[/lua]
override that
Sorry, you need to Log In to post a reply to this thread.