DButton.DoClick

From GMod Wiki

Jump to: navigation, search
Function
Syntax DButton.DoClick( Panel button )
Description:
If this is set to a function, it will be called when the button is clicked.
Returns: nil
In Object: DButton
Realm: NewerClient.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=DButton.DoClick]DButton.DoClick [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Examples

DescriptionWhen the button is clicked, the title of the frame is changed to "Hello World!"
Used onNewerClient.png
Code
window = vgui.Create( "DFrame" );
	window:SetSize( 200,70 );
	window:Center();
	window:SetTitle( "DButton Test" );
	window:MakePopup();
 
button = vgui.Create( "DButton", window );
	button:SetSize( 100, 30 );
	button:SetPos( 50, 30 );
	button:SetText( "Test Button" );
	button.DoClick = function( button )
		window:SetTitle( "Hello world!" );
	end
OutputN/A


DescriptionPrints "Hi" into the console when the button is clicked.
Used onNewerClient.png
Code
makeframe = vgui.Create("DFrame")  -- make the frame
makebutton = vgui.Create("DButton") -- make the button
 
	makeframe:SetPos(50,50) -- set the frame's position
	makeframe:SetSize(320, 110) -- set the frame's size
	makeframe:SetTitle( "Hello" ) -- set the frame's title
	makeframe:SetVisible( true ) -- make it visible
	makeframe:MakePopup() -- make it popup
	makebutton:SetParent( makeframe ) -- set the button's parent
	makebutton:SetText( "Say Hi!" ) -- set the button's text
	makebutton:SetPos(5, 25) -- set the button's positio withing the frame ( because it is parented)
	makebutton:SetSize( 100, 20 ) -- set the button's size
	makebutton.DoClick = function() Msg("Hi")	end -- make the button print Hi to the console when pressed
Output"Hi" in console.
Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox