sdlInsertTrayEntryAt function

Pointer<SdlTrayEntry> sdlInsertTrayEntryAt(
  1. Pointer<SdlTrayMenu> menu,
  2. int pos,
  3. String? label,
  4. int flags,
)

Insert a tray entry at a given position.

If label is NULL, the entry will be a separator. Many functions won't work for an entry that is a separator.

An entry does not need to be destroyed; it will be destroyed with the tray.

\param menu the menu to append the entry to. \param pos the desired position for the new entry. Entries at or following this place will be moved. If pos is -1, the entry is appended. \param label the text to be displayed on the entry, or NULL for a separator. \param flags a combination of flags, some of which are mandatory. \returns the newly created entry, or NULL if pos is out of bounds.

\since This function is available since SDL 3.2.0.

\sa SDL_TrayEntryFlags \sa SDL_GetTrayEntries \sa SDL_RemoveTrayEntry \sa SDL_GetTrayEntryParent

extern SDL_DECLSPEC SDL_TrayEntry *SDLCALL SDL_InsertTrayEntryAt(SDL_TrayMenu *menu, int pos, const char *label, SDL_TrayEntryFlags flags)

Implementation

Pointer<SdlTrayEntry> sdlInsertTrayEntryAt(
    Pointer<SdlTrayMenu> menu, int pos, String? label, int flags) {
  final sdlInsertTrayEntryAtLookupFunction = libSdl3.lookupFunction<
      Pointer<SdlTrayEntry> Function(Pointer<SdlTrayMenu> menu, Int32 pos,
          Pointer<Utf8> label, Uint32 flags),
      Pointer<SdlTrayEntry> Function(Pointer<SdlTrayMenu> menu, int pos,
          Pointer<Utf8> label, int flags)>('SDL_InsertTrayEntryAt');
  final labelPointer = label != null ? label.toNativeUtf8() : nullptr;
  final result =
      sdlInsertTrayEntryAtLookupFunction(menu, pos, labelPointer, flags);
  calloc.free(labelPointer);
  return result;
}