DModelSelect - Find Out If Someone Clicked A Model


I’ve been messing around with DERMA’s DModelSelect panel and I’ve been looking to see if there is a way to check if a player clicks on a model but can’t find anything.

Is it possible?



Nvm, for a different element. Sorry.

If you enable mouse input ( ) then you can use the following functions:

local _panel = vgui.Create( "DModelPanel" ); -- DAdjustableModelPanel?
-- ... other set up

// Key Codes:
function _panel:OnMousePressed( _key )
	-- ... // action when mouse button is pressed on element

function _panel:OnMouseReleased( _key )
	-- ... // action when mouse button is released


Confused DModelSelect with DModelPanel.

I don’t think you guys have paid attention to what element OP is requesting help with. DModelSelect populates itself with several SpawnIcons and OP wants to know what icon was clicked.

DModelSelect inherits from DPanelSelect, which when populated using SetModelList or AddPanel will take care of adding a DoClick function on the newly added panel. That click function will call DPanelSelect:SelectPanel which will finally call DPanelSelect:OnActivePanelChanged which is where you can deal with the clicked icon.

yourDModelSelector.OnActivePanelChanged = function(self,oldIcon,newIcon)
    --newIcon should be instance of SpawnIcon if you are using the default method of populating DModelSelect
    print("Clicked on",newIcon:GetModelName())