From 5418de45aa48b70a113824316f3b172d5cd597ed Mon Sep 17 00:00:00 2001 From: Brad Grantham Date: Fri, 2 Dec 2016 14:57:55 -0800 Subject: [PATCH] drag files onto screen to paste contents --- interface.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/interface.cpp b/interface.cpp index 12a3775..4d7f879 100644 --- a/interface.cpp +++ b/interface.cpp @@ -818,6 +818,25 @@ struct apple2screen : public widget paddle_buttons[0] = false; } } + + virtual bool drop(double now, float x, float y, int count, const char** paths) + { + // insert + float w, h; + tie(w, h) = get_min_dimensions(); + if(x >= 0 && y >= 0 & x < w && y < h) { + FILE *fp = fopen(paths[0], "r"); + fseek(fp, 0, SEEK_END); + long length = ftell(fp); + fseek(fp, 0, SEEK_SET); + char *text = (char *)malloc(length); + fread(text, 1, length, fp); + event_queue.push_back({PASTE, 0, text}); + fclose(fp); + return true; + } + return false; + } }; struct text_widget : public widget