Garry's Mod Wiki



An image button.

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


Derives from DButton.


string DImageButton:GetImage()
Returns the "image" of the DImageButton. Equivalent of DImage:GetImage.
boolean DImageButton:GetStretchToFit()
Returns whether the image inside the button should be stretched to fit it or not See DImageButton:SetStretchToFit
DImageButton:SetColor( table color )
Sets the color of the image. Equivalent of DImage:SetImageColor
We advise against using this. It may be changed or removed in a future update. Alias of DImageButton:SetImage.
DImageButton:SetImage( string strImage, string strBackup )
Sets the "image" of the DImageButton. Equivalent of DImage:SetImage.
DImageButton:SetImageVisible( boolean visible )
Hides or shows the image of the image button. Internally this calls Panel:SetVisible on the internal DImage.
DImageButton:SetKeepAspect( boolean keep )
Sets whether the DImageButton should keep the aspect ratio of its image. Equivalent of DImage:SetKeepAspect. Note that this will not try to fit the image inside the button, but instead it will fill the button with the image.
DImageButton:SetMaterial( IMaterial mat )
Sets a Material directly as an image. Equivalent of DImage:SetMaterial.
DImageButton:SetOnViewMaterial( string mat, string backup )
See DImage:SetOnViewMaterial
DImageButton:SetStretchToFit( boolean stretch )
Sets whether the image inside the DImageButton should be stretched to fill the entire size of the button, without preserving aspect ratio. If set to false, the image will not be resized at all.


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

Page Links

Special Pages



Render Time: 36ms

DB GetPage 2
Generate Html 9
SaveChanges (1) 8
Render Body 0
Render Sidebar 14