MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / EventMessageHook

Method EventMessageHook

Source/Engine/Platform/SDL/SDLPlatform.Windows.cpp:33–67  ·  view source on GitHub ↗

The events for releasing the mouse during window dragging are missing, handle the mouse release event here

Source from the content-addressed store, hash-verified

31
32// The events for releasing the mouse during window dragging are missing, handle the mouse release event here
33bool SDLCALL SDLPlatform::EventMessageHook(void* userdata, MSG* msg)
34{
35 if (msg->message == WM_NCLBUTTONDOWN)
36 {
37 Window* window = WindowsManager::GetByNativePtr(msg->hwnd);
38 Float2 mousePosition(static_cast<float>(static_cast<LONG>(WINDOWS_GET_X_LPARAM(msg->lParam))), static_cast<float>(static_cast<LONG>(WINDOWS_GET_Y_LPARAM(msg->lParam))));
39
40 WinImpl::DraggedWindow = window;
41 WinImpl::DraggedWindowStartPosition = window->GetClientPosition();
42 WinImpl::DraggedWindowMousePosition = mousePosition - WinImpl::DraggedWindowStartPosition;
43 WinImpl::DraggedWindowSize = window->GetClientSize();
44
45 bool result = false;
46 WindowHitCodes hit = static_cast<WindowHitCodes>(msg->wParam);
47 window->OnHitTest(mousePosition, hit, result);
48 //if (result && hit != WindowHitCodes::Caption)
49 // return false;
50
51 if (hit == WindowHitCodes::Caption)
52 {
53 SDL_Event event{ 0 };
54 event.button.type = SDL_EVENT_MOUSE_BUTTON_DOWN;
55 event.button.down = true;
56 event.button.timestamp = SDL_GetTicksNS();
57 event.button.windowID = SDL_GetWindowID(window->GetSDLWindow());
58 event.button.button = SDL_BUTTON_LEFT;
59 event.button.clicks = 1;
60 event.button.x = WinImpl::DraggedWindowMousePosition.X;
61 event.button.y = WinImpl::DraggedWindowMousePosition.Y;
62
63 SDL_PushEvent(&event);
64 }
65 }
66 return true;
67}
68
69bool SDLPlatform::InitInternal()
70{

Callers

nothing calls this directly

Calls 3

GetSDLWindowMethod · 0.80
GetClientSizeMethod · 0.45
OnHitTestMethod · 0.45

Tested by

no test coverage detected