sdlSetClipboardText function

int sdlSetClipboardText(
  1. String? text
)

Put UTF-8 text into the clipboard.

\param text the text to store in the clipboard \returns 0 on success or a negative error code on failure; call SDL_GetError() for more information.

\since This function is available since SDL 2.0.0.

\sa SDL_GetClipboardText \sa SDL_HasClipboardText

extern DECLSPEC int SDLCALL SDL_SetClipboardText(const char *text)

Implementation

int sdlSetClipboardText(String? text) {
  final sdlSetClipboardTextLookupFunction = libSdl2.lookupFunction<
      Int32 Function(Pointer<Utf8> text),
      int Function(Pointer<Utf8> text)>('SDL_SetClipboardText');
  final textPointer = text != null ? text.toNativeUtf8() : nullptr;
  final result = sdlSetClipboardTextLookupFunction(textPointer);
  calloc.free(textPointer);
  return result;
}