Table of Contents

Class TextField

Namespace
Terminal.Gui
Assembly
Terminal.Gui.dll

Single-line text entry View

public class TextField : View, IDisposable, ISupportInitializeNotification, ISupportInitialize
Inheritance
TextField
Implements
Derived
Inherited Members

Remarks

The TextFieldView provides editing functionality and mouse support.

Constructors

TextField()

Initializes a new instance of the TextField class using Computed positioning.

Properties

Autocomplete

Provides autocomplete context menu based on suggestions at the current cursor position. Configure ISuggestionGenerator to enable this feature.

Caption

Gets or sets the text to render in control when no value has been entered yet and the View does not yet have input focus.

CaptionColor

Gets or sets the foreground Color to use when rendering Caption.

ContextMenu

Get the ContextMenu for this view.

CursorPosition

Sets or gets the current cursor position.

HasHistoryChanges

Indicates whatever the text has history changes or not. true if the text has history changes false otherwise.

IsDirty

Indicates whatever the text was changed or not. true if the text was changed false otherwise.

ReadOnly

If set to true its not allow any changes in the text.

ScrollOffset

Gets the left offset position.

Secret

Sets the secret property. This makes the text entry suitable for entering passwords.

SelectedLength

Length of the selected text.

SelectedStart

Start position of the selected text.

SelectedText

The selected text.

Text

Sets or gets the text held by the view.

Used

Tracks whether the text field should be considered "used", that is, that the user has moved in the entry, so new input should be appended at the cursor position, rather than clearing the entry

Methods

ClearAllSelection()

Clear the selected text.

ClearHistoryChanges()

Allows clearing the HistoryText.HistoryTextItem items updating the original text.

Copy()

Copy the selected text to the clipboard.

Cut()

Cut the selected text to the clipboard.

DeleteAll()

Deletes all text.

DeleteCharLeft(bool)

Deletes the character to the left.

DeleteCharRight()

Deletes the character to the right.

GetNormalColor()

Determines the current ColorScheme based on the Enabled value.

InsertText(string, bool)

Inserts the given toAdd text at the current cursor position exactly as if the user had just typed it

KillWordBackwards()

Deletes word backwards.

KillWordForwards()

Deletes word forwards.

MoveEnd()

Moves cursor to the end of the typed text.

OnDrawContent(Rectangle)

Draws the view's content, including Subviews.

OnInvokingKeyBindings(Key)

Low-level API called when a user presses a key; invokes any key bindings set on the view. This is called during NewKeyDownEvent(Key) after OnKeyDown(Key) has returned.

OnLeave(View)

Method invoked when a view loses focus.

OnMouseEvent(MouseEvent)

Called when a mouse event occurs within the view's Viewport.

OnProcessKeyDown(Key)

Processes key presses for the TextField. The TextField control responds to the following keys:

KeysFunction
Delete, BackspaceDeletes the character before cursor.

OnTextChanging(string)

Virtual method that invoke the TextChanging event if it's defined.

Paste()

Paste the selected text from the clipboard.

PositionCursor()

Sets the cursor position.

Redo()

Redoes the latest changes.

SelectAll()

Selects all text.

Undo()

Undoes the latest changes.

Events

TextChanging

Changing event, raised before the Text changes and can be canceled or changing the new text.