Garry's Mod Wiki

PropSelect

Description

Used in Sandbox tools to allow the player to select models out of a list. Despite being only used in Sandbox, it is not exclusive to that gamemode.

See also MatSelect for the material selecting alternative.

Parent

Derives methods, etc not listed on this page from ContextBase.

Implements

Implements or overrides the following hooks/methods. If you want to override these, you probably want to call the original function too.

Events

PropSelect:OnRightClick( Panel pnl )
Called when the player right clicks a model. By default, this opens a menu that lets the player copy the model path.
PropSelect:OnSelect( Panel pnl, String model )
Called when the player selects a model.
PropSelect:SelectModel( SpawnIcon icon )
This is used internally - although you're able to use it you probably shouldn't. Use PropSelect:FindAndSelectButton instead. Selects a given spawnicon panel.

Methods

PropSelect:AddModel( string model, table convars )
Adds a new model to the selection list.
PropSelect:AddModelEx( string value, string model, number skin )
Adds a new model to the selection list.
PropSelect:FindAndSelectButton( string mdl )
Find and select a SpawnIcon panel based on the input model path.
Find a SpawnIcon panel based on the input model path.

Example

Example usage of the panel.

local frame = vgui.Create( "DFrame" ) frame:SetSize( 500, 500 ) frame:Center() frame:MakePopup() local PropSelect = vgui.Create( "PropSelect", frame ) PropSelect:Dock( TOP ) --PropSelect:SetConVar( "my_convar_name" ) local items = { "models/props_c17/FurnitureWashingmachine001a.mdl", "models/props_junk/PlasticCrate01a.mdl", "models/props_junk/wood_pallet001a.mdl" } for k, model in pairs( items ) do PropSelect:AddModelEx( model, model, 0 ) end function PropSelect:OnSelect( model, pnl ) print( "Selected model", model, pnl ) end
Output:
image.png