I use case SDL_MOUSEBUTTONDOWN
.
Keyboard Events are registered.
When I have a console allocated and I printf inside SDL_MOUSEBUTTONDOWN
the first click is registered.
When I use SDL_ShowSimpleMessageBox
(passing the window) inside SDL_MOUSEBUTTONDOWN
the first click is neither registered (so this debugging confirms it isn’t). Neither is first case SDL_MOUSEBUTTONUP
registered.
Neither when mouse already is over window on window creation or when hovered over window afterwards.
Window created with SDL_CreateWindow("name", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, WIDTH, HEIGHT, SDL_WINDOW_RESIZABLE);
.
Neither does | SDL_WINDOW_MOUSE_FOCUS
avail.
Neither does SDL_RaiseWindow(window)
avail.
Neither does
SDL_SysWMinfo info;
SDL_VERSION(&info.version);
if (SDL_GetWindowWMInfo(window, &info)) {
EnableWindow(info.info.win.window, true);
}
(header included) avail.
But this avails:
int x, y;
SDL_GetWindowPosition(window, &x, &y);
SDL_WarpMouseGlobal(x + centerX, y + centerY);
INPUT fakeFirstClick[2];
fakeFirstClick[0].type = INPUT_MOUSE;
fakeFirstClick[0].mi.dx = 0;
fakeFirstClick[0].mi.dy = 0;
fakeFirstClick[0].mi.mouseData = 0;
fakeFirstClick[0].mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
fakeFirstClick[0].mi.time = 0;
fakeFirstClick[0].mi.dwExtraInfo = (ULONG_PTR)NULL;
fakeFirstClick[1].type = INPUT_MOUSE;
fakeFirstClick[1].mi.dx = 0;
fakeFirstClick[1].mi.dy = 0;
fakeFirstClick[1].mi.mouseData = 0;
fakeFirstClick[1].mi.dwFlags = MOUSEEVENTF_LEFTUP;
fakeFirstClick[1].mi.time = 0;
fakeFirstClick[1].mi.dwExtraInfo = (ULONG_PTR)NULL;
SendInput(2, fakeFirstClick, sizeof(INPUT));
I think SDL_WarpMouseInWindow(...)
didn’t warp the mouse pointer after window creation (I don’t remember exactly).
Visual Studio 2022, Intel C++ Compiler, Windows 11
SDL 2.28.4