Garry's Mod Wiki

DTextEntry:OnLoseFocus

  DTextEntry:OnLoseFocus()

Description

Called whenever the DTextEntry lose focus.

Example

concommand.Add( "test_textentry_onlosefocus", function(ply) local frame = vgui.Create( "DFrame" ) frame:SetSize( 400, 200 ) frame:Center() frame:MakePopup() local default = "Brick with bob" local textentry = vgui.Create( "DTextEntry", frame ) textentry:SetText( default ) textentry:Dock( TOP ) textentry.OnLoseFocus = function( self ) if ( self:GetText() == "" ) then self:SetText( default ) end end end )
Output: DTextEntry value reset to default value if the text entered is empty.