Property SelectedStart
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:
<ul><li>
<xref href="Terminal.Gui.Views.TextField.SelectedStart" data-throw-if-not-resolved="false"></xref>: The anchor point where selection began (can be before or
after insertion point)
</li><li><xref href="Terminal.Gui.Views.TextField.InsertionPoint" data-throw-if-not-resolved="false"></xref>: The current end of the selection</li><li><xref href="Terminal.Gui.Views.TextField.SelectedLength" data-throw-if-not-resolved="false"></xref>: The absolute length of the selection</li></ul>
Example: In text "Hello World", selecting "World" by shift+clicking:
<ul><li>
If insertion point was at position 6 and user shift-clicks at position 11: SelectedStart=6,
InsertionPoint=11
</li><li>
If insertion point was at position 11 and user shift-clicks at position 6: SelectedStart=11,
InsertionPoint=6
</li><li>In both cases, SelectedLength=5 and SelectedText="World"</li></ul>
Setting this property triggers Terminal.Gui.Views.TextField.PrepareSelection(System.Int32,System.Int32) to update the selection state.
- See Also