Garry's Mod Wiki

DMenu:AddSubMenu

Panel, Panel DMenu:AddSubMenu( string Name, function func = nil )

Description

Add a sub menu to the DMenu

Arguments

1 string Name
Name of the sub menu.
2 function func = nil
Function to execute when this sub menu is clicked.

Returns

1 Panel
The created sub DMenu
2 Panel
The created DMenuOption

Example

Creates a menu with one option "Do you want to die?", which has two sub-options "Yes" and "No".

local parentMenu = DermaMenu() local subMenu, parentMenuOption = parentMenu:AddSubMenu("Do you want to die?") parentMenuOption:SetIcon("icon16/user_red.png") local yesOption = subMenu:AddOption("Yes", function() LocalPlayer():ConCommand("kill") end) yesOption:SetIcon("icon16/accept.png") local noOption = subMenu:AddOption("No", function() print("You chose to live another day") end) noOption:SetIcon("icon16/cross.png") parentMenu:Open()
Output:

Page Links


Special Pages


Wikis

?

Render Time: 42ms

DB GetPage 2
Generate Html 15
SaveChanges (1) 10
Render Body 0
Render Sidebar 12