Garry's Mod Wiki

Button

Description

We advise against using this. It may be changed or removed in a future update. Only exists for backwards compatibility with Panel:SetActionFunction. Use DButton instead.

Cant seem to figure out why the source link wont do line highlighting on this one so here is github permalink

View source

Parent

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

Implements

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

Example

Creates a button with the text "Click Me" that when pressed prints "Hello World!" in the console.

local frame = vgui.Create( "DFrame" ) frame:SetTitle( "Button example" ) frame:SetSize( 200, 100 ) frame:MakePopup() frame:Center() local button = vgui.Create( "Button" , frame ) button:Dock( FILL ) button:SetVisible( true ) button:SetText( "Click Me" ) function button:OnMousePressed() print( "Hello World!" ) end
Output:
Button_Example.png