User Tools

Site Tools


en:tutorials:display:drag_and_drop

This is an old revision of the document!


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)
{
	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.1536576110.txt.gz · Last modified: 2018/09/10 06:41 (6 years ago) (external edit)