mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-14 16:14:38 +00:00
Merge pull request #2091 from Areloch/DragNDrop
Enables SDL's ability to drag and drop files onto the game window
This commit is contained in:
commit
d7361f85a8
1 changed files with 40 additions and 0 deletions
|
|
@ -230,6 +230,13 @@ PlatformWindow *PlatformWindowManagerSDL::createWindow(GFXDevice *device, const
|
||||||
Con::warnf("PlatformWindowManagerSDL::createWindow - created a window with no device!");
|
Con::warnf("PlatformWindowManagerSDL::createWindow - created a window with no device!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Set it up for drag-n-drop events
|
||||||
|
#ifdef TORQUE_TOOLS
|
||||||
|
SDL_EventState(SDL_DROPBEGIN, SDL_ENABLE);
|
||||||
|
SDL_EventState(SDL_DROPFILE, SDL_ENABLE);
|
||||||
|
SDL_EventState(SDL_DROPCOMPLETE, SDL_ENABLE);
|
||||||
|
#endif
|
||||||
|
|
||||||
linkWindow(window);
|
linkWindow(window);
|
||||||
|
|
||||||
return window;
|
return window;
|
||||||
|
|
@ -311,6 +318,39 @@ void PlatformWindowManagerSDL::_process()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case(SDL_DROPBEGIN):
|
||||||
|
{
|
||||||
|
if (!Con::isFunction("onDropBegin"))
|
||||||
|
break;
|
||||||
|
|
||||||
|
Con::executef("onDropBegin");
|
||||||
|
}
|
||||||
|
|
||||||
|
case (SDL_DROPFILE):
|
||||||
|
{
|
||||||
|
// In case if dropped file
|
||||||
|
if (!Con::isFunction("onDropFile"))
|
||||||
|
break;
|
||||||
|
|
||||||
|
char* fileName = evt.drop.file;
|
||||||
|
|
||||||
|
if (!Platform::isFile(fileName))
|
||||||
|
break;
|
||||||
|
|
||||||
|
Con::executef("onDropFile", StringTable->insert(fileName));
|
||||||
|
|
||||||
|
SDL_free(fileName); // Free dropped_filedir memory
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case(SDL_DROPCOMPLETE):
|
||||||
|
{
|
||||||
|
if (!Con::isFunction("onDropEnd"))
|
||||||
|
break;
|
||||||
|
|
||||||
|
Con::executef("onDropEnd");
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
//Con::printf("Event: %d", evt.type);
|
//Con::printf("Event: %d", evt.type);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue