Garry's Mod Wiki

DMenuBar

Description

A simple Derma MenuBar

Parent

Derives from DPanel.

Methods

Panel DMenuBar:AddMenu( string label )
Creates a new DMenu object tied to a DButton with the given label on the menu bar. This will create a new menu regardless of whether or not one with the same label exists. To add or get a menu, use DMenuBar:AddOrGetMenu.
Panel DMenuBar:AddOrGetMenu( string label )
Retrieves a DMenu object from the menu bar. If one with the given label doesn't exist, a new one is created. To add a DMenu without checking, use DMenuBar:AddMenu.
table DMenuBar:GetBackgroundColor()
Returns the DMenuBar's background color
boolean DMenuBar:GetDisabled()
Returns whether or not the DMenuBar is disabled
boolean DMenuBar:GetDrawBackground()
We advise against using this. It may be changed or removed in a future update. Use DMenuBar:GetPaintBackground instead. Returns whether or not the background should be painted. Is the same as DMenuBar:GetPaintBackground
boolean DMenuBar:GetIsMenu()
Returns whether or not the panel is a menu. Used for closing menus when another panel is selected.
Panel DMenuBar:GetOpenMenu()
If a menu is visible/opened, then the menu is returned.
boolean DMenuBar:GetPaintBackground()
Returns whether or not the background should be painted. Is the same as DMenuBar:GetDrawBackground
DMenuBar:SetBackgroundColor( table color )
Sets the background color
DMenuBar:SetDisabled( boolean disable )
Sets whether or not the panel is disabled
DMenuBar:SetDrawBackground( boolean shouldPaint )
We advise against using this. It may be changed or removed in a future update. Use DMenuBar:SetPaintBackground Sets whether or not the background should be painted. Is the same as DMenuBar:SetPaintBackground
DMenuBar:SetIsMenu( boolean isMenu )
Sets whether or not the panel is a menu. Used for closing menus when another panel is selected.
DMenuBar:SetPaintBackground( boolean shouldPaint )
Sets whether or not the background should be painted. Is the same as DMenuBar:SetDrawBackground

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)

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

Page Links


Special Pages


Wikis

?

Render Time: 33ms

DB GetPage 3
Generate Html 10
SaveChanges (1) 11
Render Body 0
Render Sidebar 7