sdlSetPrimarySelectionText function

bool sdlSetPrimarySelectionText(
  1. String? text
)

Put UTF-8 text into the primary selection.

\param text the text to store in the primary selection. \returns true on success or false on failure; call SDL_GetError() for more information.

\threadsafety This function should only be called on the main thread.

\since This function is available since SDL 3.1.3.

\sa SDL_GetPrimarySelectionText \sa SDL_HasPrimarySelectionText

extern SDL_DECLSPEC bool SDLCALL SDL_SetPrimarySelectionText(const char *text)

Implementation

bool sdlSetPrimarySelectionText(String? text) {
  final sdlSetPrimarySelectionTextLookupFunction = libSdl3.lookupFunction<
      Uint8 Function(Pointer<Utf8> text),
      int Function(Pointer<Utf8> text)>('SDL_SetPrimarySelectionText');
  final textPointer = text != null ? text.toNativeUtf8() : nullptr;
  final result = sdlSetPrimarySelectionTextLookupFunction(textPointer) == 1;
  calloc.free(textPointer);
  return result;
}