In This Article

IHitTestResult Interface

Provides the base requirements for the hit test results of a call to the SyntaxEditor.HitTest(Point) method.

public interface IHitTestResult

Properties

IntraTextSpacerTag

Gets the intra-text spacer tag range that is directly under the Location, if any.

TagSnapshotRange<IIntraTextSpacerTag> IntraTextSpacerTag { get; }

Property Value

TagSnapshotRange<IIntraTextSpacerTag>:

The intra-text spacer tag range that is directly under the Location, if any.

Location

Gets the Point for which the hit test result was created, relative to the SyntaxEditor.

Point Location { get; }

Property Value

Point:

The Point for which the hit test result was created, relative to the SyntaxEditor.

Offset

Gets the zero-based offset within the Snapshot that is directly under the Location, or closest to it.

int Offset { get; }

Property Value

Int32:

The zero-based offset within the Snapshot that is directly under the Location, or closest to it.

Remarks

If the Location is directly over a character, the Type property returns HitTestResultType.ViewTextAreaOverCharacter and this property indicates the offset of the character. Otherwise, the offset of the nearest character is used. For instance, locations over the line number margin will return the offset of the first character in the view line that the mouse is over.

The value will be -1 if the Location is not over an editor view.

Position

Gets the zero-based TextPosition within the Snapshot that is directly under the Location, or closest to it.

TextPosition Position { get; }

Property Value

TextPosition:

The zero-based TextPosition within the Snapshot that is directly under the Location, or closest to it.

Remarks

If the Location is directly over a character, the Type property returns HitTestResultType.ViewTextAreaOverCharacter and this property indicates the TextPosition of the character. Otherwise, the position of the nearest character is used. For instance, locations over the line number margin will return the position of the first character in the view line that the mouse is over.

The value will be TextPosition.Empty if the Location is not over an editor view.

Snapshot

Gets the ITextSnapshot that was current within the View when the hit test was performed.

ITextSnapshot Snapshot { get; }

Property Value

ITextSnapshot:

The ITextSnapshot that was current within the View when the hit test was performed.

SyntaxEditor

Gets the SyntaxEditor that was hit tested.

SyntaxEditor SyntaxEditor { get; }

Property Value

SyntaxEditor:

The SyntaxEditor that was hit tested.

TextAreaLocation

Gets the Location value but in Point relative to the View's text area.

Point TextAreaLocation { get; }

Property Value

Point:

The Location value but in Point relative to the View's text area.

Remarks

This location is useful for calls to methods like IEditorView.LocationToPosition(Point, LocationToPositionAlgorithm).

Type

Gets a HitTestResultType that provides a general categorization about what the hit test result represents.

HitTestResultType Type { get; }

Property Value

HitTestResultType:

A HitTestResultType that provides a general categorization about what the hit test result represents.

View

Gets the IEditorView, if any, that the Location is over.

IEditorView View { get; }

Property Value

IEditorView:

The IEditorView, if any, that the Location is over.

ViewLine

Gets the ITextViewLine that contains the Position.

ITextViewLine ViewLine { get; }

Property Value

ITextViewLine:

The ITextViewLine that contains the Position.

Remarks

See the remarks on the Position property for details on how it is populated.

ViewMargin

Gets the IEditorViewMargin, if any, that the Location is over.

IEditorViewMargin ViewMargin { get; }

Property Value

IEditorViewMargin:

The IEditorViewMargin, if any, that the Location is over.

VisualElement

Gets the FrameworkElement, if any, that is related to the hit test result.

FrameworkElement VisualElement { get; }

Property Value

FrameworkElement:

The FrameworkElement, if any, that is related to the hit test result.

Methods

GetReader()

Returns an ITextSnapshotReader that is initialized to the Offset and allows for reading of nearby text and tokens.

ITextSnapshotReader GetReader()

Returns

ITextSnapshotReader:

An ITextSnapshotReader that is initialized to the Offset.