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.
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.
Parent
Derives methods, etc not listed on this page from TextEntry.
Implements
Implements or overrides the following hooks/methods. If you want to override these, you probably want to call the original function too.
Events
DTextEntry:OnChange()
Called 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.
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.
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:OnValueChange( string value )
Called 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 (default is false)
Methods
DTextEntry:AddHistory( string text )
Adds an entry to DTextEntry's history.
See DTextEntry:SetHistoryEnabled.
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.
If you are looking for a way to modify character limits, see Panel:SetMaximumCharCount
Returns whether a string is numeric or not.
Always returns false if the DTextEntry:SetNumeric is set to false.
Called by the DTextEntry when a list of autocompletion options is requested. Meant to be overridden.
table DTextEntry:GetCursorColor()
Returns the cursor color of a DTextEntry.
boolean DTextEntry:GetDisabled()
We advise against using this. It may be changed or removed in a future update.
Use Panel:IsEnabled instead.
Returns whether the textbox is disabled. Use Panel:IsEnabled instead.
boolean DTextEntry:GetDrawBackground()
We advise against using this. It may be changed or removed in a future update.
Alias of DTextEntry:GetPaintBackground. Use that instead.
Whether the background is displayed or not.
boolean DTextEntry:GetDrawBorder()
We advise against using this. It may be changed or removed in a future update.
Returns the value set by DTextEntry:SetDrawBorder.
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.
table DTextEntry:GetHighlightColor()
Returns the highlight/text selection color of the text entry. If it was not overwritten, it will return the derma skin value. (colTextEntryTextHighlight)
boolean DTextEntry:GetHistoryEnabled()
Returns whether the history functionality of DTextEntry is enabled. See DTextEntry:AddHistory.
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.
boolean DTextEntry:GetPaintBackground()
Whether the background is displayed or not
table DTextEntry:GetPlaceholderColor()
Return current color of panel placeholder
string DTextEntry:GetPlaceholderText()
Returns the placeholder text set with DTextEntry:SetPlaceholderText.
boolean DTextEntry:GetTabbingDisabled()
Returns whether or not the panel accepts tab key.
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.
Returns whether this DTextEntry is being edited or not. (i. e. has 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. This is an implementation of TextEntry:OnTextChanged
You should not override this function. Use DTextEntry:OnValueChange instead.
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:SetDrawBackground( boolean show )
We advise against using this. It may be changed or removed in a future update.
Alias of DTextEntry:SetPaintBackground. Use that instead.
DTextEntry:SetDrawBorder( boolean bool )
We advise against using this. It may be changed or removed in a future update.
Does nothing.
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:SetHighlightColor( table color )
Sets/overrides the default highlight/text selection color of the text entry.
DTextEntry:SetHistoryEnabled( boolean enable )
Enables or disables the history functionality of DTextEntry. This allows the player to scroll through history elements using up and down arrow keys.
See DTextEntry:AddHistory.
DTextEntry:SetNumeric( boolean numericOnly )
Sets whether or not to decline non-numeric characters as input.
Numeric characters are 1234567890. -
DTextEntry:SetPaintBackground( boolean show )
Sets whether to show the default background of the DTextEntry.
DTextEntry:SetPlaceholderColor( table color = Color(128, 128, 128) )
Allow you to set placeholder color.
DTextEntry:SetPlaceholderText( string text = "nil" )
Sets the placeholder text that will be shown while the text entry has no user text. The player will not need to delete the placeholder text if they decide to start typing.
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.
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.
DTextEntry:UpdateConvarValue()
This is used internally - although you're able to use it you probably shouldn't.
Used by DTextEntry:OnTextChanged, DTextEntry:OnEnter and DTextEntry:OnLoseFocus
Updates the ConVar associated with the TextEntry to its new value.
DTextEntry:UpdateFromHistory()
This is used internally - although you're able to use it you probably shouldn't.
Used internally to set text from the history.
DTextEntry:UpdateFromMenu()
This is used internally - although you're able to use it you probably shouldn't.
Used internally to set text from the autocomplete menu.
Example
Creates a text entry form that allows you to print messages into the local player's chat window.
Output:
Example
Creates a text entry with a browse button.
Output:
(For instructions on how to make the file browser, see DFileBrowser)