DMultiChoice doesn’t have submenus, only DMenu does. But to not leave you empy handed I made an immitation.
Type TestMenu in the console to spawn it.
[LUA]
local function MakeMenu()
local DermaPanel = vgui.Create( “DFrame” )
DermaPanel:SetSize( 110,133 )
DermaPanel:Center()
DermaPanel:SetTitle( “Panel Test” )
local List= vgui.Create( "DMultiChoice", DermaPanel)
List:SetPos(5,28)
List:SetSize( 100, 20 )
List.OpenMenu = function()
local function FindParent(Panel)
if(IsValid(Panel:GetParent()) && IsValid(Panel:GetParent():GetParent()))then
return FindParent(Panel:GetParent())
else
return Panel
end
end
local MenuButtonOptions = DermaMenu() -- Creates the menu
local SubMenu = MenuButtonOptions:AddSubMenu("hello") -- Add options to the menu
SubMenu:AddOption("my", function() Msg("My") end)
SubMenu:AddOption("friend", function() Msg("Friend") end)
MenuButtonOptions:AddOption("how", function() Msg("How") end )
MenuButtonOptions:AddOption("are", function() Msg("Are") end )
MenuButtonOptions:AddOption("you", function() Msg("You") end )
MenuButtonOptions:AddOption("?", function() Msg("?") end )
MenuButtonOptions:Open() -- Open the menu AFTER adding your options
local Parent = FindParent(List) --Search for the parent to get screen position
local X,Y = Parent:GetPos()
local X2, Y2 = List:GetPos()
X = X+X2
Y = Y+List:GetTall()+Y2
MenuButtonOptions:SetPos(X, Y) --Set the position under the menu
end
end
concommand.Add(“TestMenu”, MakeMenu)
[/LUA]
Opps didn’t see your edit, oh well it’s there for a reference.