Category:DMenuBar

From Garry's Mod
Jump to: navigation, search

Contents

DescriptionPanelPage

A simple Derma MenuBar

Inherited Functions

Inherits the following functions from DPanel and its parents up to 3 levels deep:


Examples

Example

Creates a DMenuBar in a DFrame.

local Frame = vgui.Create( "DFrame" )
Frame:SetSize( 300, 200 )
Frame:Center()
Frame:MakePopup()

local MenuBar = vgui.Create( "DMenuBar", Frame )
MenuBar:DockMargin( -3, -6, -3, 0 ) --corrects MenuBar pos

local M1 = MenuBar:AddMenu( "File" )
M1:AddOption("New", function() Msg("Chose File:New\n") end):SetIcon("icon16/page_white_go.png")
M1:AddOption("Open", function() Msg("Chose File:Open\n") end):SetIcon("icon16/folder_go.png")

local M2 = MenuBar:AddMenu("Edit")
M2:AddOption("Copy", function() Msg("Chose Edit:Copy\n") end)

local M3 = MenuBar:AddMenu("Help")
M3:AddOption("About", function() Msg("Chose Help:About\n") end)


Examples

Example

A sub menu example

local frame = vgui.Create( "DFrame" )
frame:SetSize( 300, 200 )
frame:Center()
frame:MakePopup()

local menuBar = vgui.Create( "DMenuBar", frame )
menuBar:DockMargin( -3, -6, -3, 0 )

local option1 = menuBar:AddMenu( "Option 1" )
option1:AddOption( "Dummy option", function() MsgN( "Chose Dummy option" ) end )

local sub = option1:AddSubMenu( "Sub Menu" )
sub:SetDeleteSelf( false ) -- Necessary so the sub menu is not automatically removed on close
for i = 0, 5 do
	sub:AddOption( "Option " .. i, function() MsgN( "Chose sub menu option " .. i ) end )
end


Personal tools
Navigation