Class
KeyboardSelectionHandler

Word-like Shift selection engine implementing Anchor–ActiveEnd model. Anchor stays fixed during session; ActiveEnd moves exactly one NavigationUnit per request;

Definition

Namespace:Telerik.Windows.Documents.Selection

Assembly:Telerik.Windows.Controls.RichTextBox.dll

Syntax:

cs-api-definition
public class KeyboardSelectionHandler

Inheritance: objectKeyboardSelectionHandler

Constructors

KeyboardSelectionHandler(RadDocument)

Initializes a new instance of the KeyboardSelectionHandler class.

Declaration

cs-api-definition
public KeyboardSelectionHandler(RadDocument document)

Parameters

document

RadDocument

The RadDocument to operate on.

Properties

Document

Gets the underlying document associated with the current instance.

Declaration

cs-api-definition
protected RadDocument Document { get; }

Property Value

RadDocument

LastCaretPosition

Declaration

cs-api-definition
protected DocumentPosition LastCaretPosition { get; }

Property Value

DocumentPosition

Methods

BeginSelection(DocumentPosition)

Begins a new selection session at the specified document position.

Declaration

cs-api-definition
public void BeginSelection(DocumentPosition start)

Parameters

start

DocumentPosition

The position to start the selection from.

HandleDocumentCaretPositionChanged(bool, bool, MoveCaretDirections)

Handles logic after the caret position in the document has changed. Updates selection and internal state based on the current context.

Declaration

cs-api-definition
public void HandleDocumentCaretPositionChanged(bool isSelectionInProgress, bool shiftPressed, MoveCaretDirections direction = MoveCaretDirections.Unknown)

Parameters

isSelectionInProgress

bool

Indicates if a selection is currently in progress.

shiftPressed

bool

Indicates if the Shift key is pressed.

direction

MoveCaretDirections

The direction in which the caret was moved.

HandleDocumentCaretPositionChanging()

Handles logic before the caret position in the document changes. Updates internal state and caret snapshot as needed.

Declaration

cs-api-definition
public void HandleDocumentCaretPositionChanging()

MoveActiveEnd(NavigationUnit, Direction)

Moves the active end of the selection by one navigation unit in the specified direction, updating the selection to reflect expansion or contraction. The caller must ensure the Shift key context.

Declaration

cs-api-definition
public virtual void MoveActiveEnd(NavigationUnit unit, Direction direction)

Parameters

unit

NavigationUnit

The navigation unit to move by (character, cell, or paragraph).

direction

Direction

The direction to move the active end.