Garry's Mod Wiki

DButton:DoClick

  DButton:DoClick()

Description

Called when the button is left clicked (on key release) by the player.

This will be called after DButton:IsDown.

See also DButton:DoRightClick.

Example

Creates a 100 x 100 pixel button in the center of the screen, that prints Hello World! to the Chat and disappears when clicked.

local DermaButton = vgui.Create( "DButton" ) -- Creates our button DermaButton:SetText( "Click me!" ) DermaButton:SetSize( 100, 100 ) DermaButton:Center() DermaButton:SetMouseInputEnabled( true ) -- We must accept mouse input function DermaButton:DoClick() -- Defines what should happen when the label is clicked chat.AddText("Hello World!") self:Remove() end
Output:
Hello World!

When the button was clicked.