New to Telerik UI for WPFStart a free 30-day trial

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:

C#
public class KeyboardSelectionHandler

Inheritance: objectKeyboardSelectionHandler

Constructors

Initializes a new instance of the KeyboardSelectionHandler class.

C#
public KeyboardSelectionHandler(RadDocument document)
Parameters:documentRadDocument

The RadDocument to operate on.

Properties

Gets the underlying document associated with the current instance.

C#
protected RadDocument Document { get; }
C#
protected DocumentPosition LastCaretPosition { get; }

Methods

Begins a new selection session at the specified document position.

C#
public void BeginSelection(DocumentPosition start)
Parameters:startDocumentPosition

The position to start the selection from.

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

C#
public void HandleDocumentCaretPositionChanged(bool isSelectionInProgress, bool shiftPressed, MoveCaretDirections direction = MoveCaretDirections.Unknown)
Parameters:isSelectionInProgressbool

Indicates if a selection is currently in progress.

shiftPressedbool

Indicates if the Shift key is pressed.

directionMoveCaretDirections

The direction in which the caret was moved.

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

C#
public void HandleDocumentCaretPositionChanging()

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.

C#
public virtual void MoveActiveEnd(NavigationUnit unit, Direction direction)
Parameters:unitNavigationUnit

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

directionDirection

The direction to move the active end.