TextHit Struct
The character of a TextLayout a point is on, or the nearest one: what TextLayout.HitTest finds.
public readonly struct TextHit : IEquatable<TextHit>Remarks
A character is what a reader takes for one: a letter with its marks, an emoji sequence (a grapheme cluster). Its leading edge is where it starts in the direction of its text: its left in a left-to-right text, its right in a right-to-left one.
- Implements
Properties
| Name | Description |
|---|---|
| CaretIndex | Gets the position in the text a caret takes when the point is clicked: before the character, or after it when the point is nearer to its end. It is an index TextLayout.GetCaretRectangle accepts. |
| IsInside | Gets a value indicating whether the point is on the character: false for a point above, below or beside the text, which gives the nearest character. |
| IsTrailing | Gets a value indicating whether the point is nearer to the end of the character than to its start, in the direction of its text. |
| Length | Gets the number of UTF-16 code units of the character: 0 on a line that has no character. |
| LineIndex | Gets the index of the line the point is on, or of the nearest line, in TextLayout.Lines. |
| TextIndex | Gets the index in the text of the first UTF-16 code unit of the character. |
CaretIndex
TextHit.csGets the position in the text a caret takes when the point is clicked: before the character, or after it when the point is nearer to its end. It is an index TextLayout.GetCaretRectangle accepts.
public int CaretIndex { get; }Property value
IsInside
TextHit.csIsTrailing
TextHit.csLength
TextHit.csLineIndex
TextHit.csGets the index of the line the point is on, or of the nearest line, in TextLayout.Lines.
public int LineIndex { get; }Property value
TextIndex
TextHit.csMethods
| Name | Description |
|---|---|
| Equals(TextHit) | Indicates whether the current object is equal to another object of the same type. |
| Equals(object?) | Indicates whether this instance and a specified object are equal. |
| GetHashCode() | Returns the hash code for this instance. |
| ToString() | Returns the line, the character and the side of the hit. |
GetHashCode()
TextHit.csToString()
TextHit.csOperators
| Name | Description |
|---|---|
| operator ==(TextHit, TextHit) | Compares two hits for equality. |
| operator !=(TextHit, TextHit) | Compares two hits for inequality. |