Hello, so I’ve been working with SDL for a while and I just found a really strange behaviour on the DropXXX events. If I run my program by double clicking it, drag and drop events work correctly, but if I run it from the terminal it simply does not work, those events seem to even be disabled because the window does not recognize them. I also tried running it from RemedyBG trying to debug the error, but with RemedyBG it does indeed break on the event and therefore, within RemedyBG the event also works correctly. I was worried it was becaused something wrong on my base code, but it is reproducilble even with SDL’s Wiki example. I’m working on Windows btw.
// Example program:
// SDL_DropEvent usage
#include "SDL.h"
int main(int argc, char *argv[]) {
SDL_bool done;
SDL_Window *window;
SDL_Event event; // Declare event handle
char* dropped_filedir; // Pointer for directory of dropped file
SDL_Init(SDL_INIT_VIDEO); // SDL2 initialization
window = SDL_CreateWindow( // Create a window
"SDL_DropEvent usage, please drop the file on window",
SDL_WINDOWPOS_CENTERED,
SDL_WINDOWPOS_CENTERED,
640,
480,
SDL_WINDOW_OPENGL
);
// Check that the window was successfully made
if (window == NULL) {
// In the event that the window could not be made...
SDL_Log("Could not create window: %s", SDL_GetError());
SDL_Quit();
return 1;
}
SDL_EventState(SDL_DROPFILE, SDL_ENABLE);
done = SDL_FALSE;
while (!done) { // Program loop
while (!done && SDL_PollEvent(&event)) {
switch (event.type) {
case (SDL_QUIT): { // In case of exit
done = SDL_TRUE;
break;
}
case (SDL_DROPFILE): { // In case if dropped file
dropped_filedir = event.drop.file;
// Shows directory of dropped file
SDL_ShowSimpleMessageBox(
SDL_MESSAGEBOX_INFORMATION,
"File dropped on window",
dropped_filedir,
window
);
SDL_free(dropped_filedir); // Free dropped_filedir memory
break;
}
}
}
SDL_Delay(0);
}
SDL_DestroyWindow(window); // Close and destroy the window
SDL_Quit(); // Clean up
return 0;
}
Just compile that program and see how it behaves in from the terminal and just from double clicking. Is this a known error? I could not find that much information about this problem. If anyone knows something on why this is happening or how to fix it, let me know pls!
Thank you so much in advance.