DLabel/DoDoubleClick

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

DescriptionPanelHook

Called when the label is double clicked by the player with left clicks.

DLabel:SetDoubleClickingEnabled must be set to true for this hook to work, which it is by default.

This will be called after DLabel:OnDepressed and DLabel:OnReleased and DLabel:DoClick.

See also DLabel:DoRightClick and DLabel:DoMiddleClick.

Examples

Example

Opens a URL in Steam Overlay by double clicking the text "Click ME"!

local frame = vgui.Create( "DFrame" )
frame:SetTitle( "Double Click Example" )
frame:SetSize( 250, 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( "Double click me!" )
frame_label:SizeToContents()
frame_label:SetMouseInputEnabled( true )
frame_label.DoDoubleClick = function()
	gui.OpenURL("https://wiki.garrysmod.com/")
end

-- Uncommentiing this will disable double clicking
-- frame_label:SetDoubleClickingEnabled( false )

Output:

ClickMeDouble.png
Personal tools
Navigation