SDL_DropEvent(3type)

✨ SDL_DropEvent ✨

okay so bestie, gather round, because this is the SDL3 DATATYPES moment where we talk about SDL_DropEvent β€” the lil struct that shows up when somebody drops text on your app or when the system is like "hey, open this file for me". You'll find it hanging out in the event.drop.* family πŸ’–


🌸 NAME 🌸

SDL_DropEvent β€” an event used to drop text or request a file open by the system (that's the event.drop.* crew, iykyk) 🫢


✨ SYNOPSIS ✨

#include <SDL3/SDL_events.h>

typedef struct SDL_DropEvent
{
    SDL_EventType type; /**< SDL_EVENT_DROP_BEGIN or SDL_EVENT_DROP_FILE or SDL_EVENT_DROP_TEXT or SDL_EVENT_DROP_COMPLETE or SDL_EVENT_DROP_POSITION */
    Uint32 reserved;
    Uint64 timestamp;   /**< In nanoseconds, populated using SDL_GetTicksNS() */
    SDL_WindowID windowID;    /**< The window that was dropped on, if any */
    float x;            /**< X coordinate, relative to window (not on begin) */
    float y;            /**< Y coordinate, relative to window (not on begin) */
    const char *source; /**< The source app that sent this drop event, or NULL if that isn't available */
    const char *data;   /**< The text for SDL_EVENT_DROP_TEXT and the file name for SDL_EVENT_DROP_FILE, NULL for other events */
} SDL_DropEvent;

πŸ’… The Fields, One By One πŸ’…

🌈 type

An SDL_EventType, and it's gonna be one of these babes:

  • SDL_EVENT_DROP_BEGIN
  • SDL_EVENT_DROP_FILE
  • SDL_EVENT_DROP_TEXT
  • SDL_EVENT_DROP_COMPLETE
  • SDL_EVENT_DROP_POSITION

🌈 reserved

A Uint32 that is just... there. Reserved. Not your business, not my business πŸ’€

🌈 timestamp

A Uint64, measured in nanoseconds, populated using SDL_GetTicksNS(). Slay, precise to the nano ✨

🌈 windowID

An SDL_WindowID β€” the window that was dropped on, if any. No window? No problem, it just won't be there πŸͺŸ

🌈 x

A float: the X coordinate, relative to the window. (Not on begin, bestie β€” don't come for me.) πŸ“

🌈 y

A float: the Y coordinate, relative to the window. (Also not on begin. Same deal.) πŸ“

🌈 source

A const char * β€” the source app that sent this drop event, or NULL if that isn't available. Sometimes the mystery stays a mystery πŸ™ˆ

🌈 data

A const char * β€” this one's the moment fr fr: it's the text for SDL_EVENT_DROP_TEXT, and the file name for SDL_EVENT_DROP_FILE. For other events? NULL. Periodt. πŸŽ€


πŸ‘‘ AVAILABILITY πŸ‘‘

This struct has been available since SDL 3.2.0. It's giving established, it's giving iconic πŸ’œ


not me being emotionally attached to a struct with eight fields. anyway, if you're handling drops, check type first, then go grab your data β€” you got this πŸ¦‹

okay bestie that's the whole page!! this came to you courtesy of Simple Directmedia Layer, version SDL 3.4.18, and it's the SDL_DropEvent(3type) manual page β€” mwah, go drop something cute πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from