Category:DImageButton

From Garry's Mod
Jump to: navigation, search

Contents

DescriptionPanelPage

An image button.

This panel inherits all methods of DButton, such as DLabel:DoClick.

Inherited Functions

Inherits the following functions from DButton and its parents up to 3 levels deep:


Examples

Example

The DImageButton is the same as the DImage, but you can click it. When you hover over it, you will get the default link cursor on Windows.

local frame = vgui.Create( "DFrame" )
frame:SetSize( 300, 250 )
frame:Center()
frame:MakePopup()

DermaImageButton = vgui.Create( "DImageButton", frame )
DermaImageButton:SetPos( 25, 50 )				// Set position
//DermaImageButton:SetSize( 16, 16 )			// OPTIONAL: Use instead of SizeToContents() if you know/want to fix the size
DermaImageButton:SetImage( "icon16/bomb.png" )	// Set the material - relative to /materials/ directory
DermaImageButton:SizeToContents()				// OPTIONAL: Use instead of SetSize if you want to resize automatically ( without stretching )
DermaImageButton.DoClick = function()
	Msg( "You clicked the image!" )
end


Personal tools
Navigation