Garry's Mod Wiki

Revision Difference

DTextEntry#528818

<panel> <parent>TextEntry</parent> <description> A form which may be used to display text the player is meant to select and copy or alternately allow them to enter some text of their own . Do note that at least one of your DTextEntry's parents must either be an <page>EditablePanel</page> or derived from it (like a <page>DFrame</page>, for example), else it won't be able to focus and thus be unselectable. You must also call <page>Panel:MakePopup</page> on said panel or the DTextEntry will not work. ⤶ <bug issue="1588">This does not clear out previously-pasted text properly.</bug>⤶ </description> </panel> ⤶ ⤶ <example>⤶ <description>Creates a text entry form that allows you to print messages into the local player's chat window.</description> ⤶ <example>⤶ <description>Creates a text entry form that allows you to print messages into the local player's chat window.⤶ </description> <code> local frame = vgui.Create( "DFrame" ) frame:SetSize( 400, 200 ) frame:Center() frame:MakePopup() ⤶ local TextEntry = vgui.Create( "DTextEntry", frame ) -- create the form as a child of frame⤶ TextEntry:SetPos( 25, 50 )⤶ TextEntry:SetSize( 75, 85 ) TextEntry:SetValue( "Placeholder Text" ) TextEntry.OnEnter = function( self )⤶ chat.AddText( self:GetValue() ) -- print the form's text as server text⤶ end⤶ concommand.Add( "test_textentry", function(ply) local frame = vgui.Create( "DFrame" ) frame:SetSize( 400, 200 ) frame:Center() frame:MakePopup()⤶ ⤶ local TextEntry = vgui.Create( "DTextEntry", frame ) -- create the form as a child of frame⤶ TextEntry:Dock( TOP ) TextEntry.OnEnter = function( self ) chat.AddText( self:GetValue() ) -- print the textentry text as a chat message⤶ end⤶ ⤶ local TextEntryPH = vgui.Create( "DTextEntry", frame )⤶ TextEntryPH:Dock( TOP )⤶ TextEntryPH:DockMargin( 0, 5, 0, 0 )⤶ TextEntryPH:SetPlaceholderText( "I am a placeholder" )⤶ TextEntryPH.OnEnter = function( self )⤶ chat.AddText( self:GetValue() )⤶ end⤶ end )⤶ </code> <output><image src="DTextEntryExample.png"/></output>⤶ ⤶ </example>⤶ <output>⤶ <upload src="70c/8d88bebe8e67219.png" size="11372" name="image.png" />⤶ </output>⤶ </example>⤶ # Methods * <page>AddHistory</page>⤶ * <page>GetDisabled</page>⤶ * <page>GetDrawBackground</page>⤶ * <page>GetDrawBorder</page>⤶ * <page>GetFont</page>⤶ * <page>GetHighlightColor</page>⤶ * <page>GetHistoryEnabled</page>⤶ * <page>GetTabbingDisabled</page>⤶ * <page>OnKeyCode</page>⤶ * <page>OnLoseFocus</page>⤶ * <page>SetDrawBackground</page>⤶ * <page>SetDrawBorder</page>⤶ * <page>SetHighlightColor</page>⤶ * <page>SetHistoryEnabled</page>⤶ * <page>SetTabbingDisabled</page>⤶ * <page>UpdateConvarValue</page>⤶ * <page>UpdateFromHistory</page>⤶ * <page>UpdateFromMenu</page>⤶ # Undocumented Methods * <page>DTextEntry:AddHistory</page>⤶ * <page>DTextEntry:GetDisabled</page>⤶ * <page>DTextEntry:GetDrawBackground</page>⤶ * <page>DTextEntry:GetDrawBorder</page>⤶ * <page>DTextEntry:GetFont</page>⤶ * <page>DTextEntry:GetHighlightColor</page>⤶ * <page>DTextEntry:GetHistoryEnabled</page>⤶ * <page>DTextEntry:GetTabbingDisabled</page>⤶ * <page>DTextEntry:SetDrawBackground</page>⤶ * <page>DTextEntry:SetDrawBorder</page>⤶ * <page>DTextEntry:SetHighlightColor</page>⤶ * <page>DTextEntry:SetHistoryEnabled</page>⤶ * <page>DTextEntry:UpdateConvarValue</page>⤶ * <page>DTextEntry:UpdateFromHistory</page>⤶ * <page>DTextEntry:UpdateFromMenu</page>