User Tools

Site Tools


Drag and Drop

Actually, really just drop. Orx supports being able to drop files onto the game window. Very neat for writing applications in Orx and being able to add or load files that are dragged onto it.

Start by adding a System Event Handler in the Init() function:

orxEvent_AddHandler(orxEVENT_TYPE_SYSTEM, SystemEventHandler);

Then the function itself:

orxSTATUS orxFASTCALL SystemEventHandler(const orxEVENT *_pstEvent)
    if(_pstEvent->eID == orxSYSTEM_EVENT_DROP)
        orxSYSTEM_EVENT_PAYLOAD *payload = (orxSYSTEM_EVENT_PAYLOAD *)_pstEvent->pstPayload;
        orxU32 filesDroppedCount = payload->stDrop.u32Number;
        const orxSTRING *filenameList = payload->stDrop.azValueList;
        for (int i=0; i<filesDroppedCount; i++)
            const orxSTRING fileName = filenameList[i];

This function will be executed if there is a system event (like a Drop event) and the payload will be retrieved where we can find the details of what was dropped onto the window.

Compile it and try it. Load a file browser and select one or more files. Drag them onto the Orx game window. The number of files will be retrieved, and then all the file names retrieved by looping over them.

en/tutorials/display/drag_and_drop.txt · Last modified: 2018/09/10 13:39 (5 weeks ago) by iarwain