DTextEntry.OnGetFocus

From GMod Wiki

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



Examples

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

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox