Table of Contents

Class PrimarySelection

Namespace
Sdl3Sharp.Video.Windowing
Assembly
Sdl3Sharp.dll

Provides methods for accessing the system's so called primary selection

public static class PrimarySelection
Inheritance
PrimarySelection
Inherited Members

Remarks

The X11 and Wayland video targets have a concept of the "primary selection" in addition to the usual clipboard. This is generally highlighted (but not explicitly copied) text from various apps. While the methods for interacting with the primary selection are also offered on platforms without this concept, on those platforms only text set by the app will be kept for later retrieval by the very same app; the operating system will not ever attempt to change the text externally if it doesn't support a primary selection.

For interaction with the primary selection to be available, the Video sub system must be initialized (either while initializing SDL or by initializing it on its own).

Methods

HasText()

Determines whether there is text available in the primary selection and it's not an empty string

public static bool HasText()

Returns

bool

true if the primary selection contains non-empty text; otherwise, false.

Remarks

This method should only be called on the main thread.

TryGetText(out string?)

Tries to get text from the primary selection

public static bool TryGetText(out string? text)

Parameters

text string

The text from the primary selection, or null if text from the primary selection couldn't get successfully obtained

Returns

bool

true, if text from the primary selection was successfully obtained; otherwise, false (check TryGet(out string?) for more information)

Remarks

This method may result an empty string for text, if there was not enough memory left for a copy of the primary selection's content.

This method should only be called on the main thread.

TrySetText(string?)

Tries to set text as the primary selection

public static bool TrySetText(string? text)

Parameters

text string

The text to store in the primary selection

Returns

bool

true, if the text was successfully stored in the primary selection; otherwise, false (check TryGet(out string?) for more information)

Remarks

This method should only be called on the main thread.