From Garry's Mod
Called when the label is left clicked (on key release) by the player.
Creates a label in the center of the screen, that prints I was clicked! to the console and disappears when clicked.
local lbl = vgui.Create( "DLabel" ) -- Creates our label lbl:SetFont( "DermaLarge" ) lbl:SetText( "Click me!" ) lbl:SizeToContents() lbl:Center() lbl:SetMouseInputEnabled( true ) -- We must accept mouse input function lbl:DoClick() -- Defines what should happen when the label is clicked print("I was clicked!") self:Remove() end
I was clicked!When the label is clicked.