sdlSetClipboardData function clipboard

bool sdlSetClipboardData(
  1. Pointer<NativeFunction<SdlClipboardDataCallback>> callback,
  2. Pointer<NativeFunction<SdlClipboardCleanupCallback>> cleanup,
  3. Pointer<NativeType> userdata,
  4. Pointer<Pointer<Int8>> mimeTypes,
  5. int numMimeTypes,
)

Offer clipboard data to the OS.

Tell the operating system that the application is offering clipboard data for each of the provided mime-types. Once another application requests the data the callback function will be called, allowing it to generate and respond with the data for the requested mime-type.

The size of text data does not include any terminator, and the text does not need to be null-terminated (e.g., you can directly copy a portion of a document).

\param callback a function pointer to the function that provides the clipboard data. \param cleanup a function pointer to the function that cleans up the clipboard data. \param userdata an opaque pointer that will be forwarded to the callbacks. \param mime_types a list of mime-types that are being offered. SDL copies the given list. \param num_mime_types the number of mime-types in the mime_types list. \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.2.0.

\sa SDL_ClearClipboardData \sa SDL_GetClipboardData \sa SDL_HasClipboardData

extern SDL_DECLSPEC bool SDLCALL SDL_SetClipboardData(SDL_ClipboardDataCallback callback, SDL_ClipboardCleanupCallback cleanup, void *userdata, const char **mime_types, size_t num_mime_types)

Implementation

bool sdlSetClipboardData(
  Pointer<NativeFunction<SdlClipboardDataCallback>> callback,
  Pointer<NativeFunction<SdlClipboardCleanupCallback>> cleanup,
  Pointer<NativeType> userdata,
  Pointer<Pointer<Int8>> mimeTypes,
  int numMimeTypes,
) {
  final sdlSetClipboardDataLookupFunction = _libSdl
      .lookupFunction<
        Uint8 Function(
          Pointer<NativeFunction<SdlClipboardDataCallback>> callback,
          Pointer<NativeFunction<SdlClipboardCleanupCallback>> cleanup,
          Pointer<NativeType> userdata,
          Pointer<Pointer<Int8>> mimeTypes,
          Uint32 numMimeTypes,
        ),
        int Function(
          Pointer<NativeFunction<SdlClipboardDataCallback>> callback,
          Pointer<NativeFunction<SdlClipboardCleanupCallback>> cleanup,
          Pointer<NativeType> userdata,
          Pointer<Pointer<Int8>> mimeTypes,
          int numMimeTypes,
        )
      >('SDL_SetClipboardData');
  return sdlSetClipboardDataLookupFunction(
        callback,
        cleanup,
        userdata,
        mimeTypes,
        numMimeTypes,
      ) ==
      1;
}