Garry's Mod Wiki

DTextEntry

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 EditablePanel or derived from it (like a DFrame, for example), else it won't be able to focus and thus be unselectable. You must also call Panel:MakePopup on said panel or the DTextEntry will not work.

This does not clear out previously-pasted text properly.

Issue Tracker: 1588

Parent

Derives from TextEntry.

Methods

boolean DTextEntry:AllowInput( string char )
Called whenever the value of the panel has been updated (whether by user input or otherwise). It allows you to determine whether a user can modify the TextEntry's text. By default, this only checks whether the panel disallows numeric characters, preventing it from being edited if the value contains any. This is actually an engine hook that only works on TextEntry derived elements.
boolean DTextEntry:CheckNumeric( string strValue )
Returns whether a string is numeric or not. Always returns false if the DTextEntry:SetNumeric is set to false.
table DTextEntry:GetAutoComplete( string inputText )
Called by the DTextEntry when a list of autocompletion options is requested. Meant to be overridden. Options can be selected by arrow keys, it doesn't support mouse clicks. Fixed in the next update.
table DTextEntry:GetCursorColor()
Returns the cursor color of a DTextEntry.
boolean DTextEntry:GetEnterAllowed()
Returns whether pressing Enter can cause the panel to lose focus. Note that a multiline DTextEntry cannot be escaped using the Enter key even when this function returns true.
number DTextEntry:GetFloat()
Returns the contents of the DTextEntry as a number.
number DTextEntry:GetInt()
Similar to DTextEntry:GetFloat, but rounds the value to the nearest integer.
boolean DTextEntry:GetNumeric()
Returns whether only numeric characters (123456789.-) can be entered into the DTextEntry.
table DTextEntry:GetPlaceholderColor()
Return current color of panel placeholder
table DTextEntry:GetTextColor()
Returns the text color of a DTextEntry.
boolean DTextEntry:GetUpdateOnType()
Returns whether the DTextEntry is set to run DTextEntry:OnValueChange every time a character is typed or deleted or only when Enter is pressed.
boolean DTextEntry:IsEditing()
Returns whether this DTextEntry is being edited or not. (i.e. has focus)
boolean DTextEntry:IsMultiline()
Determines whether or not DTextEntry is in multi-line mode. This is set with DTextEntry:SetMultiline.
DTextEntry:OnChange()
Called internally by DTextEntry:OnTextChanged when the user modifies the text in the DTextEntry. You should override this function to define custom behavior when the DTextEntry text changes.
DTextEntry:OnEnter( string value )
Called whenever enter is pressed on a DTextEntry. DTextEntry:IsEditing will still return true in this callback!
DTextEntry:OnGetFocus()
Called whenever the DTextEntry gains focus.
DTextEntry:OnKeyCode( number keyCode )
Called from DTextEntry's TextEntry:OnKeyCodeTyped override whenever a valid character is typed while the text entry is focused.
DTextEntry:OnLoseFocus()
Called whenever the DTextEntry lose focus.
DTextEntry:OnTextChanged( boolean noMenuRemoval )
This is used internally - although you're able to use it you probably shouldn't. Called internally when the text inside the DTextEntry changes. You should not override this function. Use DTextEntry:OnValueChange instead.
DTextEntry:OnValueChange( string value )
Called internally when the text changes of the DTextEntry are applied. (And set to the attached console variable, if one is given) See also DTextEntry:OnChange for a function that is called on every text change, even if the console variable is not updated. You should override this function to define custom behavior when the text changes. This method is called: When Enter is pressed after typing When DTextEntry:SetValue is used For every key typed - only if DTextEntry:SetUpdateOnType was set to true (defa..
DTextEntry:OpenAutoComplete( table tab )
This is used internally - although you're able to use it you probably shouldn't. You really should be using DTextEntry:GetAutoComplete instead. Builds a DMenu for the DTextEntry based on the input table.
DTextEntry:SetCursorColor( table color )
Sets the cursor's color in DTextEntry (the blinking line).
DTextEntry:SetDisabled( boolean disabled )
We advise against using this. It may be changed or removed in a future update. Use Panel:SetEnabled instead. Disables input on a DTextEntry and greys it out visually. This differs from DTextEntry:SetEditable which doesn't visually change the textbox.
DTextEntry:SetEditable( boolean enabled )
Disables Input on a DTextEntry. This differs from DTextEntry:SetDisabled - SetEditable will not affect the appearance of the textbox.
DTextEntry:SetEnterAllowed( boolean allowEnter )
Sets whether pressing the Enter key will cause the DTextEntry to lose focus or not, provided it is not multiline. This is true by default.
DTextEntry:SetFont( string font )
Changes the font of the DTextEntry.
DTextEntry:SetMultiline( boolean multiline )
Enables or disables the multi-line functionality of DTextEntry.
DTextEntry:SetNumeric( boolean numericOnly )
Sets whether or not to decline non-numeric characters as input. Numeric characters are 1234567890.-
DTextEntry:SetPlaceholderColor( table color = Color(128, 128, 128) )
Allow you to set placeholder color.
DTextEntry:SetPlaceholderText( string text = "nil" )
Allow you to add a hint.
DTextEntry:SetTabbingDisabled( boolean enabled )
Sets whether or not the panel accepts tab key. Disabling tab key prevents the panel from unfocusing by mouse, however, still works for focusing to other keyboard focus.
DTextEntry:SetTextColor( table color )
Sets the text color of the DTextEntry.
DTextEntry:SetUpdateOnType( boolean updateOnType )
Sets whether we should fire DTextEntry:OnValueChange every time we type or delete a character or only when Enter is pressed.
DTextEntry:SetValue( string text )
Sets the text of the DTextEntry and calls DTextEntry:OnValueChange. The text of the DTextEntry only changes if it's not currently being typed in. If you would rather set the text regardless, use Panel:SetText.

Example

Creates a text entry form that allows you to print messages into the local player's chat window.

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
Output:

Methods

Page Links


Special Pages


Wikis

?

Render Time: 114ms

DB GetPage 49
Generate Html 34
SaveChanges (1) 10
Render Body 0
Render Sidebar 18