Table of Contents

Class TextField

Namespace
Terminal.Gui.Views
Assembly
Terminal.Gui.dll

Single-line text editor.

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

Remarks

The TextField View 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 Context Menu 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()

Clears the history.

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.

Dispose(bool)

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

EnableForDesign()

Causes the View to enable design-time mode. This typically means that the view will load demo data and be configured to allow for design-time manipulation.

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.

OnGettingAttributeForRole(in VisualRole, ref Attribute)

Called when the Attribute for a GetAttributeForRole(VisualRole) is being retrieved. Implementations can return true to stop further processing and optionally set the Attribute in the event args to a different value.

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.

Paste()

Paste the selected text from the clipboard.

PositionCursor()

Sets the cursor position.

RaiseTextChanging(ResultEventArgs<string>)

Raises the TextChanging event, enabling canceling the change or adjusting the text.

Redo()

Redoes the latest changes.

SelectAll()

Selects all text.

Undo()

Undoes the latest changes.

Events

TextChanging

Raised before Text changes. The change can be canceled the text adjusted.