Table of Contents

Property SelectedStart

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

SelectedStart

Gets or sets the anchor position where text selection began, measured as a 0-based index into text elements.

public int SelectedStart { get; set; }

Property Value

int

The starting position of the selection, or -1 if no selection is active. The value is clamped to the range [-1, Text.Length].

Remarks

Selection model: TextField uses an anchor-based selection model:

Example: In text "Hello World", selecting "World" by shift+clicking:

  • If insertion point was at position 6 and user shift-clicks at position 11: SelectedStart=6, InsertionPoint=11
  • If insertion point was at position 11 and user shift-clicks at position 6: SelectedStart=11, InsertionPoint=6
  • In both cases, SelectedLength=5 and SelectedText="World"

Setting this property triggers PrepareSelection(int, int) to update the selection state.

See Also