A popup context menu (fl_menu), built on DScrollPanel. Create it, add entries with add_option and add_spacer, then call open to show it at the cursor or at a given position. It is registered with Derma's menu system, so it is removed when the Derma menus are closed. The action menu of an item is built with it.

Summary

Methods

Adds a clickable option to the bottom of the menu.
Adds a thin horizontal divider below the last option.
Tells the Derma menu system to remove this menu when menus are closed.
Init()client
Starts the menu with the padding that its options are inset by.
Opens the menu as a popup at the given screen position and registers it to be closed together with other Derma menus.
Draws the card of the menu.
Makes the menu and all of its options as wide as the widest option and as tall as the options combined, capped at 75% of the screen height.

Methods

PANEL:add_option(name, callback)

client packages/active_ui/views/base/cl_menu.lua:190

Adds a clickable option to the bottom of the menu.

local item_menu = vgui.Create('fl_menu')

local use_button = item_menu:add_option(t(item_obj:get_use_text()), function()
  item_obj:do_menu_action('on_use')
end)

use_button:SetIcon(item_obj.use_icon or 'icon16/accept.png')

item_menu:open()

Parameters

  • name String text of the option
  • callback Function optional, defaults to nil called with the option's panel when it is clicked

Returns

  • Panel the created fl_menu_item

PANEL:add_spacer(px)

client packages/active_ui/views/base/cl_menu.lua:217

Adds a thin horizontal divider below the last option.

Parameters

  • px Number optional, defaults to 1 height of the divider in pixels

Returns

  • Panel the created divider

PANEL:GetDeleteSelf()

client packages/active_ui/views/base/cl_menu.lua:146

Tells the Derma menu system to remove this menu when menus are closed.

Returns

  • Boolean always true

Starts the menu with the padding that its options are inset by.

Opens the menu as a popup at the given screen position and registers it to be closed together with other Derma menus.

Parameters

  • x Number optional, defaults to gui.MouseX()
  • y Number optional, defaults to gui.MouseY()

Returns

  • Panel the menu itself

Draws the card of the menu.

Parameters

  • w Number panel width
  • h Number panel height

PANEL:PerformLayout()

client packages/active_ui/views/base/cl_menu.lua:113

Makes the menu and all of its options as wide as the widest option and as tall as the options combined, capped at 75% of the screen height.

Defined in