DTextEntry.OnLoseFocus

From GMod Wiki

Jump to: navigation, search
Function
Syntax DTextEntry:OnLoseFocus( Panel TextEntry Object )
Where is this used?
Description:
Called when a DTextEntry loses focus (i.e. when the user clicks away from it).
Returns: nil
Part of Library: DTextEntry
Realm: NewerClient.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=DTextEntry.OnLoseFocus]DTextEntry.OnLoseFocus [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Examples

DescriptionAlert the user when the DTextEntry loses focus.
Used onNewerClient.png
Code
local ParentPanel = vgui.Create("DFrame")
	ParentPanel:SetSize(ScrW()/7, ScrH()/12)
	ParentPanel:Center()
	ParentPanel:SetTitle("OnLoseFocus Test")
	ParentPanel:SetDeleteOnClose(true)
	ParentPanel:MakePopup()
 
local TextEntry = vgui.Create( "DTextEntry", ParentPanel )
	TextEntry:SetSize(ScrW()/9, ScrH()/30)
	TextEntry:SetValue("OnLoseFocus Test")
	TextEntry:SetPos(ParentPanel:GetWide()/2-TextEntry:GetWide()/2,
	ParentPanel:GetTall()/2-TextEntry:GetTall()/5)
	TextEntry:SetEnterAllowed(false)
 
	TextEntry.OnLoseFocus = function(PanelVar) -- Passes a single argument, the text entry object.
		LocalPlayer():ChatPrint("Lost Focus!")
	end
OutputPrints Lost Focus! to the player's chat area when the DTextEntry loses focus.

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox