Hi,
I’m facing a subtle but nontheless annoying issue with the current SDL2/SDL3 libraries and maybe someone can give me a hint if either I’m doing something wrong or if this is a bug in the library.
Problem: Drag and Drop to the SDL window does not work.
For demonstration purposes, I wrote the following minimum demo:
#include <stdio.h>
#include <SDL3/SDL.h>
typedef unsigned char boolean;
#define TRUE (1)
#define FALSE (0)
int main(int argc, char **argv)
{
SDL_Window *window=NULL;
SDL_Event event;
boolean quit=FALSE;
SDL_Init(SDL_INIT_VIDEO);
window=SDL_CreateWindow("Drop Test",640,480,0);
while(!quit)
{
while(SDL_PollEvent(&event))
{
switch(event.type)
{
case SDL_EVENT_QUIT:
quit=TRUE;
break;
case SDL_EVENT_DROP_BEGIN:
fprintf(stdout,"event: DROP_BEGIN\n");
break;
case SDL_EVENT_DROP_FILE:
fprintf(stdout,"event: DROP_FILE\n");
break;
case SDL_EVENT_DROP_TEXT:
fprintf(stdout,"event: DROP_TEXT\n");
break;
case SDL_EVENT_DROP_COMPLETE:
fprintf(stdout,"event: DROP_COMPLETE\n");
break;
case SDL_EVENT_DROP_POSITION:
fprintf(stdout,"event: DROP_POSITION\n");
break;
default:
break;
}
}
}
return 0;
}
As soon as something is dropped on the window, no event is created but the following error message is spit out in the Terminal:
BHandler w>Drop Test: MessageReceived() couldn't understand the message:
BMessage('DATA') {
src_window = (type = 'PNTR')(size = 8)
click_pt = BPoint(x:994.000000, y:43.000000)
TrackerViewToken = (type = 'MSNG')(size = 24)
refs = entry_ref(device=3, directory=1572870, name="notes.txt", path="/boot/home/Desktop/notes.txt")
buttons = int32(0x1 or 1)
_drop_point_ = BPoint(x:639.000000, y:385.000000)
_drop_offset_ = BPoint(x:31.125000, y:15.750000)
}
It does not matter if I use SDL2 or SDL3, it’s the same behavior.
Any ideas?
With kind regards,
Egon