DMenu/AddSubMenu

From Garry's Mod
Jump to: navigation, search
 DMenu:AddSubMenu( )

Contents

DescriptionPanelFunc

Add a sub menu to the DMenu

Arguments

string Name

Name of the sub menu.

Arguments

function func=nil

Function to execute when this sub menu is clicked.

Returns

Panel

The created sub DMenu

Returns

Panel

The created DMenuOption

Examples

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:

DMenuSubMenu.png
Personal tools
Navigation