Garry's Mod Wiki

SANDBOX:SpawnmenuIconMenuOpen

  SANDBOX:SpawnmenuIconMenuOpen( Panel menu, Panel icon, string contentType )

Recently Added

This was recently added in version (2025.03.18). It might only be available on the Dev Branch right now.

Description

Called when the player opens a context menu by right clicking one of the spawnmenu icons. Either ContentIcon or SpawnIcon.

This hook can be used to add new custom menu options to the context menu.

Arguments

1 Panel menu
The DMenu to add options to.
2 Panel icon
The ContentIcon or SpawnIcon that was right clicked. It will be a SpawnIcon for model content type, and a ContentIcon for all others.
3 string contentType
The content type, such as:
  • weapon
  • entity
  • vehicle
  • npc
  • model
  • tool
  • postprocess

Addon related icons may have different types.

Example

Adds a "copy name" option to NPC spawn icons.

hook.Add( "SpawnmenuIconMenuOpen", "SM_CopyNPCName", function( menu, icon, contentType ) if ( contentType != "npc" ) then return end menu:AddOption( "Copy Name", function() SetClipboardText( language.GetPhrase( icon.m_NiceName ) ) end ):SetIcon( "icon16/page_copy.png" ) end)