diff render_sdl.c @ 1397:89eb967fed72

Initial support for drag and drop. Some work needed for proper menu integration.
author Michael Pavone <pavone@retrodev.com>
date Wed, 14 Jun 2017 09:48:46 -0700
parents 8c6d2ed3b959
children 08116cb5ffaa
line wrap: on
line diff
--- a/render_sdl.c	Mon Jun 12 21:12:28 2017 -0700
+++ b/render_sdl.c	Wed Jun 14 09:48:46 2017 -0700
@@ -914,6 +914,12 @@
 	[SDL_SCANCODE_KP_PERIOD] = 0x71,
 };
 
+static drop_handler drag_drop_handler;
+void render_set_drag_drop_handler(drop_handler handler)
+{
+	drag_drop_handler = handler;
+}
+
 static int32_t handle_event(SDL_Event *event)
 {
 	switch (event->type) {
@@ -986,6 +992,12 @@
 			break;
 		}
 		break;
+	case SDL_DROPFILE:
+		if (drag_drop_handler) {
+			drag_drop_handler(event->drop.file);
+		}
+		SDL_free(event->drop.file);
+		break;
 	case SDL_QUIT:
 		puts("");
 		exit(0);