Table of Contents

Struct TextEditingEvent

Namespace
Sdl3Sharp.Events
Assembly
Sdl3Sharp.dll

Represents an event that occurs when text editing happens

public struct TextEditingEvent : ICommonEvent<TextEditingEvent>, ICommonEvent, ISpanFormattable, IFormattable
Implements
Inherited Members

Remarks

Associated EventTypes:

Properties

Length

Gets or sets the length of the selected editing text

public int Length { readonly get; set; }

Property Value

int

The length of the selected editing text, as a length in number of characters, or -1 if not set

Remarks

The length is the number of characters that will be replaced by new typing.

Reading and writing this property can be very expensive, you should consider caching it's value. If you want to get the Text, Start, and Length simultaneously, consider using the GetTextStartAndLength() method as it's way more efficient when getting all three quantities at once.

Start

Gets or set the starting cursor of the selected editing text

public int Start { readonly get; set; }

Property Value

int

The starting cursor of the selected editing text, as a position in number of characters, or -1 if not set

Remarks

The starting cursor is the position, in number of characters, where new typing will be inserted into the editing text.

Reading and writing this property can be very expensive, you should consider caching it's value. If you want to get the Text, Start, and Length simultaneously, consider using the GetTextStartAndLength() method as it's way more efficient when getting all three quantities at once.

Text

Gets the editing text

public string? Text { readonly get; set; }

Property Value

string

The editing text

Remarks

Reading this property can be very expensive, you should consider caching it's value. If you want to get the Text, Start, and Length simultaneously, consider using the GetTextStartAndLength() method as it's way more efficient when getting all three quantities at once.

Setting this property is not supported and will lead the property to throw a NotSupportedException.

Exceptions

NotSupportedException

When setting this property

Timestamp

Gets or sets the timestamp of the current event

public ulong Timestamp { readonly get; set; }

Property Value

ulong

The timestamp of the current event, in nanoseconds in nanoseconds since the initialization of SDL

Remarks

The value of this property usually describes the time passed, in nanoseconds since the initialization of SDL. It can be properly populated by using NanosecondTicks.

Type

Gets or sets the type of the current event

public EventType Type { readonly get; set; }

Property Value

EventType

The type of the current event

Remarks

When setting this property, the value must be TextEditing. Otherwise, it will lead the property to throw an ArgumentException!

Exceptions

ArgumentException

When setting this property, the value was not TextEditing

WindowId

Gets or sets the window Id of the Window with keyboard focus, if any

public uint WindowId { readonly get; set; }

Property Value

uint

The window Id of the Window with keyboard focus, if any, or 0

Methods

GetTextStartAndLength()

Gets the editing text, the starting cursor of the selected editing text, and the length of the selected editing text simultaneously

public readonly (string? Text, int Start, int Length) GetTextStartAndLength()

Returns

(string Text, int Start, int Length)

The editing text, the starting cursor of the selected editing text, as a position in number of characters, or -1 if not set, and length of the selected editing text, as a length in number of characters, or -1 if not set

Remarks

The starting cursor is the position, in number of characters, where new typing will be inserted into the editing text.

The resulting length is the number of characters that will be replaced by new typing.

Calling this method can be very expensive, you should consider caching it's return values.

ToString()

Returns the fully qualified type name of this instance.

public override readonly string ToString()

Returns

string

The fully qualified type name.

ToString(IFormatProvider?)

Formats the value of the current instance using the specified format.

public readonly string ToString(IFormatProvider? formatProvider)

Parameters

formatProvider IFormatProvider

The provider to use to format the value.

-or-

A null reference (Nothing in Visual Basic) to obtain the numeric format information from the current locale setting of the operating system.

Returns

string

The value of the current instance in the specified format.

ToString(string?)

Formats the value of the current instance using the specified format.

public readonly string ToString(string? format)

Parameters

format string

The format to use.

-or-

A null reference (Nothing in Visual Basic) to use the default format defined for the type of the IFormattable implementation.

Returns

string

The value of the current instance in the specified format.

ToString(string?, IFormatProvider?)

Formats the value of the current instance using the specified format.

public readonly string ToString(string? format, IFormatProvider? formatProvider)

Parameters

format string

The format to use.

-or-

A null reference (Nothing in Visual Basic) to use the default format defined for the type of the IFormattable implementation.

formatProvider IFormatProvider

The provider to use to format the value.

-or-

A null reference (Nothing in Visual Basic) to obtain the numeric format information from the current locale setting of the operating system.

Returns

string

The value of the current instance in the specified format.

TryFormat(Span<char>, out int, ReadOnlySpan<char>, IFormatProvider?)

Tries to format the value of the current instance into the provided span of characters.

public readonly bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format = default, IFormatProvider? provider = null)

Parameters

destination Span<char>

The span in which to write this instance's value formatted as a span of characters.

charsWritten int

When this method returns, contains the number of characters that were written in destination.

format ReadOnlySpan<char>

A span containing the characters that represent a standard or custom format string that defines the acceptable format for destination.

provider IFormatProvider

An optional object that supplies culture-specific formatting information for destination.

Returns

bool

true if the formatting was successful; otherwise, false.

Operators

explicit operator TextEditingEvent(in Event)

Converts a general Event to an event of type TextEditingEvent

public static explicit operator TextEditingEvent(in Event @event)

Parameters

event Event

The general Event to convert to an event of type TextEditingEvent

Returns

TextEditingEvent

Remarks

The Type of the given event must be TextEditing. Otherwise, it will lead the method to throw an ArgumentException!

Exceptions

ArgumentException

The Type of the given event was not TextEditing

implicit operator Event(in TextEditingEvent)

Converts an event of type TextEditingEvent to a general Event

public static implicit operator Event(in TextEditingEvent @event)

Parameters

event TextEditingEvent

The event of type TextEditingEvent to convert to a general Event

Returns

Event

Remarks

This conversion usually requires the event to be copied into a new general Event structure. Note: This can impact performance!