From 8c91699678c10b17c19c78dbc2c2607f55757659 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= <branimirkaradzic@gmail.com> Date: Wed, 3 Jan 2018 22:49:10 -0800 Subject: [PATCH] entry: Drop file event for SDL. --- examples/common/entry/entry.cpp | 8 ++++++++ examples/common/entry/entry_sdl.cpp | 14 ++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/examples/common/entry/entry.cpp b/examples/common/entry/entry.cpp index ec2d654a6..19c47e705 100644 --- a/examples/common/entry/entry.cpp +++ b/examples/common/entry/entry.cpp @@ -746,6 +746,10 @@ restart: break; case Event::DropFile: + { + const DropFileEvent* drop = static_cast<const DropFileEvent*>(ev); + DBG("%s", drop->m_filePath.get() ); + } break; default: @@ -904,6 +908,10 @@ restart: break; case Event::DropFile: + { + const DropFileEvent* drop = static_cast<const DropFileEvent*>(ev); + DBG("%s", drop->m_filePath.get() ); + } break; default: diff --git a/examples/common/entry/entry_sdl.cpp b/examples/common/entry/entry_sdl.cpp index 0425cfe27..7a1482081 100644 --- a/examples/common/entry/entry_sdl.cpp +++ b/examples/common/entry/entry_sdl.cpp @@ -488,6 +488,8 @@ namespace entry WindowHandle defaultWindow = { 0 }; setWindowSize(defaultWindow, m_width, m_height, true); + SDL_EventState(SDL_DROPFILE, SDL_ENABLE); + bx::FileReaderI* reader = NULL; while (NULL == reader) { @@ -806,6 +808,18 @@ namespace entry } break; + case SDL_DROPFILE: + { + const SDL_DropEvent& dev = event.drop; + WindowHandle handle = defaultWindow; //findHandle(dev.windowID); + if (isValid(handle) ) + { + m_eventQueue.postDropFileEvent(handle, dev.file); + SDL_free(dev.file); + } + } + break; + default: { const SDL_UserEvent& uev = event.user;