mirror of
https://github.com/encounter/SDL.git
synced 2025-12-08 13:15:10 +00:00
Added SDL_DROPBEGIN and SDL_DROPCOMPLETE events, plus window IDs for drops.
This allows an app to know when a set of drops are coming in a grouping of some sort (for example, a user selected multiple files and dropped them all on the window with a single drag), and when that set is complete. This also adds a window ID to the drop events, so the app can determine to which window a given drop was delivered. For application-level drops (for example, you launched an app by dropping a file on its icon), the window ID will be zero.
This commit is contained in:
@@ -77,10 +77,14 @@ main(int argc, char *argv[])
|
||||
while (SDL_PollEvent(&event)) {
|
||||
SDLTest_CommonEvent(state, &event, &done);
|
||||
|
||||
if ((event.type == SDL_DROPFILE) || (event.type == SDL_DROPTEXT)) {
|
||||
if (event.type == SDL_DROPBEGIN) {
|
||||
SDL_Log("Drop beginning on window %u", (unsigned int) event.drop.windowID);
|
||||
} else if (event.type == SDL_DROPCOMPLETE) {
|
||||
SDL_Log("Drop complete on window %u", (unsigned int) event.drop.windowID);
|
||||
} else if ((event.type == SDL_DROPFILE) || (event.type == SDL_DROPTEXT)) {
|
||||
const char *typestr = (event.type == SDL_DROPFILE) ? "File" : "Text";
|
||||
char *dropped_filedir = event.drop.file;
|
||||
SDL_Log("%s dropped on window: %s", typestr, dropped_filedir);
|
||||
SDL_Log("%s dropped on window %u: %s", typestr, (unsigned int) event.drop.windowID, dropped_filedir);
|
||||
SDL_free(dropped_filedir);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user