Handle focus in/out on emscripten to fix mouse button stickiness.

This commit is contained in:
Bartosz Taudul 2024-09-25 00:36:55 +02:00
parent bbbe6ce894
commit 684c34dc21
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3

View File

@ -200,6 +200,16 @@ Backend::Backend( const char* title, const std::function<void()>& redraw, const
tracy::s_wasActive = true; tracy::s_wasActive = true;
return EM_TRUE; return EM_TRUE;
} ); } );
emscripten_set_mouseleave_callback( "#canvas", nullptr, EM_TRUE, []( int, const EmscriptenMouseEvent*, void* ) -> EM_BOOL {
ImGui::GetIO().AddFocusEvent( false );
tracy::s_wasActive = true;
return EM_TRUE;
} );
emscripten_set_mouseenter_callback( "#canvas", nullptr, EM_TRUE, []( int, const EmscriptenMouseEvent*, void* ) -> EM_BOOL {
ImGui::GetIO().AddFocusEvent( true );
tracy::s_wasActive = true;
return EM_TRUE;
} );
emscripten_set_wheel_callback( "#canvas", nullptr, EM_TRUE, []( int, const EmscriptenWheelEvent* e, void* ) -> EM_BOOL { emscripten_set_wheel_callback( "#canvas", nullptr, EM_TRUE, []( int, const EmscriptenWheelEvent* e, void* ) -> EM_BOOL {
ImGui::GetIO().AddMouseWheelEvent( e->deltaX * -0.05, e->deltaY * -0.05 ); ImGui::GetIO().AddMouseWheelEvent( e->deltaX * -0.05, e->deltaY * -0.05 );
tracy::s_wasActive = true; tracy::s_wasActive = true;