DLabel/OnReleased

From Garry's Mod
Jump to: navigation, search
 DLabel:OnReleased( )

DescriptionPanelHook

Called when the player releases any mouse button on the label. This is always called after DLabel:OnDepressed.

This works as an alternative to PANEL:OnMouseReleased as that hook is used heavily by DLabel and overriding it will break functionality.

See also DLabel:DoClick, DLabel:DoMiddleClick, DLabel:DoRightClick and DLabel:DoDoubleClick.

Examples

Example

Changes the text of the label when the hook is called.

local frame = vgui.Create( "DFrame" )
frame:SetTitle( "OnDepressed/Released Example" )
frame:SetSize( 300, 100 )
frame:Center()
frame:MakePopup()

local frame_label = vgui.Create( "DLabel", frame )
frame_label:SetPos( 10, 30 )
frame_label:SetTextColor( Color( 255, 255, 255 ) )
frame_label:SetText( "Click me!" )
frame_label:SizeToContents()
frame_label:SetMouseInputEnabled( true )
frame_label.OnDepressed = function( s )
	s:SetText( "OnDepressed" )
	frame_label:SizeToContents()
end
frame_label.OnReleased = function( s )
	s:SetText( "OnReleased" )
	frame_label:SizeToContents()
end


Personal tools
Navigation