From 01e018b54cfd589b9b00f30aa436013099aa1500 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Richard=20Hoz=C3=A1k?= <5235838+richardhozak@users.noreply.github.com> Date: Mon, 14 Oct 2024 23:28:28 +0200 Subject: [PATCH] Fix scroll on mouse down being overriden by touch scroll Fixes unexpected behavior when clicking on scrollbar with mouse, the view would scroll the opposite direction as it would with touch scroll. This behavior is unexpected with mouse. The bug was probably caused by Clay_SetPointerState overriding scrollbarData and using the pointer state as scroll information for the container behind the scrollbar instead using the scrollbarData. This fixes that behavior by not passing mouse down, when mouse down is captured by scrollbar. --- examples/raylib-sidebar-scrolling-container/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/raylib-sidebar-scrolling-container/main.c b/examples/raylib-sidebar-scrolling-container/main.c index 37fa80d..bef69d3 100644 --- a/examples/raylib-sidebar-scrolling-container/main.c +++ b/examples/raylib-sidebar-scrolling-container/main.c @@ -141,7 +141,7 @@ void UpdateDrawFrame(void) //---------------------------------------------------------------------------------- // Handle scroll containers Clay_Vector2 mousePosition = RAYLIB_VECTOR2_TO_CLAY_VECTOR2(GetMousePosition()); - Clay_SetPointerState(mousePosition, IsMouseButtonDown(0)); + Clay_SetPointerState(mousePosition, IsMouseButtonDown(0) && !scrollbarData.mouseDown); Clay_SetLayoutDimensions((Clay_Dimensions) { (float)GetScreenWidth(), (float)GetScreenHeight() }); if (!IsMouseButtonDown(0)) { scrollbarData.mouseDown = false;