Added SDL_DROPTEXT event, for dragging and dropping string data.

This patch is based on work in Unreal Engine 4's fork of SDL,
compliments of Epic Games.
This commit is contained in:
Ryan C. Gordon
2016-01-05 02:26:45 -05:00
parent c3114975db
commit f9b7379341
5 changed files with 38 additions and 38 deletions

View File

@@ -27,20 +27,33 @@
#include "SDL_dropevents_c.h"
int
SDL_SendDropFile(const char *file)
static int
SDL_SendDrop(const SDL_EventType evtype, const char *data)
{
int posted;
/* Post the event, if desired */
posted = 0;
if (SDL_GetEventState(SDL_DROPFILE) == SDL_ENABLE) {
if (SDL_GetEventState(evtype) == SDL_ENABLE) {
SDL_Event event;
event.type = SDL_DROPFILE;
event.drop.file = SDL_strdup(file);
SDL_zero(event);
event.type = evtype;
event.drop.file = SDL_strdup(data);
posted = (SDL_PushEvent(&event) > 0);
}
return (posted);
return posted;
}
int
SDL_SendDropFile(const char *file)
{
return SDL_SendDrop(SDL_DROPFILE, file);
}
int
SDL_SendDropText(const char *text)
{
return SDL_SendDrop(SDL_DROPTEXT, text);
}
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -24,6 +24,7 @@
#define _SDL_dropevents_c_h
extern int SDL_SendDropFile(const char *file);
extern int SDL_SendDropText(const char *text);
#endif /* _SDL_dropevents_c_h */