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.

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 Terminal.Gui.HistoryText.HistoryTextItemEventArgs 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.

OnDrawingContent()

Called when the View's content is to be drawn. The default implementation does nothing.

OnHasFocusChanged(bool, View, View)

Invoked after HasFocus has changed. This method is called before the HasFocusChanged event is raised.

OnKeyDown(Key)

Called when the user presses a key, allowing subscribers to pre-process the key down event. Called before key bindings are invoked and KeyDownNotHandled is raised. Set Handled to true to stop the key from being processed further.

OnKeyDownNotHandled(Key)

Called when the user has pressed key it wasn't handled by KeyDown and was not bound to a key binding.

OnMouseEvent(MouseEventArgs)

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

OnTextChanging(CancelEventArgs<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.