Garry's Mod Wiki

Revision Difference

Button#561252

<panel> <parent>DButton</parent> <realm>Client and Menu</realm> <file line="153-L165">lua/vgui/dbutton.lua</file>⤶ <description> <deprecated> Only exists for backwards compatibility with <page>Panel:SetActionFunction</page>. Use <page>DButton</page> instead. </deprecated> Creates a button that players can click on. Creates a button that players can click on. [Cant seem to figure out why the source link wont do line highlighting on this one so here is github permalink](https://github.com/Facepunch/garrysmod/blob/fff01df0cfaf6152336f5026d0bedf5225052bbe/garrysmod/lua/vgui/dbutton.lua#L154C1-L166C76)⤶ ⤶ </description> <overrides> <page>PANEL:Init</page> <page>PANEL:Paint</page> <page>PANEL:PerformLayout</page> <page>Panel:GenerateExample</page> <page>Panel:SetActionFunction</page> <page>DButton:DoClick</page> <page>DButton:DoRightClick</page> </overrides> </panel> <example> <description>Creates a button with the text `"Click Me"` that when pressed prints "Hello World!" in the console.</description> <code> 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 </code> <output><upload src="b04e5/8db62a0d5b7f44e.png" size="2821" name="Button_Example.png" /></output> </example>