Garry's Mod Wiki

Garry's Mod Wiki

  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.
Function argument(s):
1 Panel pnl - The DMenuOption that was 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:

This site is a community mirror of the official Garry's Mod wiki.. This site is not maintained by Facepunch Studios.

Page content is automatically updated twice a day. Edits and history are not available.

Last Parsed: Loading...