From b4288f969c997bc58a4d196e42c03c8e710c4b4b Mon Sep 17 00:00:00 2001 From: Nomi Date: Tue, 29 Dec 2020 02:42:20 +0700 Subject: [PATCH] Add horizontal scroll (#116) Add horizontal scroll (Shift + Mouse wheel) for Scroll Panel control --- src/raygui.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/raygui.h b/src/raygui.h index fbe493c..c250719 100644 --- a/src/raygui.h +++ b/src/raygui.h @@ -896,7 +896,11 @@ Rectangle GuiScrollPanel(Rectangle bounds, Rectangle content, Vector2 *scroll) if (IsKeyDown(KEY_UP)) scrollPos.y += GuiGetStyle(SCROLLBAR, SCROLL_SPEED); } - scrollPos.y += GetMouseWheelMove()*20; + int wheelMove = GetMouseWheelMove(); + + // Horizontal scroll (Shift + Mouse wheel) + if (hasHorizontalScrollBar && (IsKeyDown(KEY_LEFT_SHIFT) || IsKeyDown(KEY_RIGHT_SHIFT))) scrollPos.x += wheelMove*20; + else scrollPos.y += wheelMove*20; // Vertical scroll } } @@ -3716,4 +3720,4 @@ static const char *CodepointToUtf8(int codepoint, int *byteLength) #if defined(__cplusplus) } // Prevents name mangling of functions -#endif \ No newline at end of file +#endif