Implement onDropStart, onDropEnd for file dropping (#1583)
* native side * Theoretically, things should work * brurh forgot a letter * another quick cpp fix * everything works now * onDropText isnt fully supported * Fix typo. * Remove accidental cSpell addition to settings.json * Dispatch `onDropStart` and `onDropEnd` events in HTML5. --------- Co-authored-by: player-03 <player3.14@gmail.com>
This commit is contained in:
@@ -11,7 +11,10 @@ namespace lime {
|
||||
|
||||
enum DropEventType {
|
||||
|
||||
DROP_FILE
|
||||
DROP_FILE,
|
||||
DROP_TEXT,
|
||||
DROP_BEGIN,
|
||||
DROP_COMPLETE
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -60,6 +60,9 @@ namespace lime {
|
||||
WindowEvent windowEvent;
|
||||
|
||||
SDL_EventState (SDL_DROPFILE, SDL_ENABLE);
|
||||
SDL_EventState (SDL_DROPTEXT, SDL_ENABLE);
|
||||
SDL_EventState (SDL_DROPBEGIN, SDL_ENABLE);
|
||||
SDL_EventState (SDL_DROPCOMPLETE, SDL_ENABLE);
|
||||
SDLJoystick::Init ();
|
||||
|
||||
#ifdef HX_MACOS
|
||||
@@ -184,6 +187,9 @@ namespace lime {
|
||||
break;
|
||||
|
||||
case SDL_DROPFILE:
|
||||
case SDL_DROPTEXT:
|
||||
case SDL_DROPBEGIN:
|
||||
case SDL_DROPCOMPLETE:
|
||||
|
||||
ProcessDropEvent (event);
|
||||
break;
|
||||
@@ -352,8 +358,27 @@ namespace lime {
|
||||
|
||||
if (DropEvent::callback) {
|
||||
|
||||
dropEvent.type = DROP_FILE;
|
||||
dropEvent.file = (vbyte*)event->drop.file;
|
||||
switch (event->type)
|
||||
{
|
||||
case SDL_DROPFILE:
|
||||
dropEvent.type = DROP_FILE;
|
||||
dropEvent.file = (vbyte*)event->drop.file;
|
||||
break;
|
||||
case SDL_DROPTEXT:
|
||||
dropEvent.type = DROP_TEXT;
|
||||
dropEvent.file = (vbyte*)event->drop.file;
|
||||
break;
|
||||
case SDL_DROPBEGIN:
|
||||
dropEvent.type = DROP_BEGIN;
|
||||
dropEvent.file = 0;
|
||||
break;
|
||||
case SDL_DROPCOMPLETE:
|
||||
dropEvent.type = DROP_COMPLETE;
|
||||
dropEvent.file = 0;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
DropEvent::Dispatch (&dropEvent);
|
||||
SDL_free (dropEvent.file);
|
||||
|
||||
@@ -44,14 +44,16 @@ namespace lime {
|
||||
|
||||
DropEvent* eventObject = (DropEvent*)DropEvent::eventObject->Get ();
|
||||
|
||||
int length = strlen ((const char*)event->file);
|
||||
char* file = (char*)malloc (length + 1);
|
||||
strcpy (file, (const char*)event->file);
|
||||
eventObject->file = (vbyte*)file;
|
||||
if (event->type == DROP_FILE || event->type == DROP_TEXT) {
|
||||
int length = strlen ((const char*)event->file);
|
||||
char* file = (char*)malloc (length + 1);
|
||||
strcpy (file, (const char*)event->file);
|
||||
eventObject->file = (vbyte*)file;
|
||||
} else {
|
||||
eventObject->file = 0;
|
||||
}
|
||||
eventObject->type = event->type;
|
||||
|
||||
}
|
||||
|
||||
DropEvent::callback->Call ();
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user