From 0a75cde80ce4e4b7ffe30c4144eba4409f65bf12 Mon Sep 17 00:00:00 2001 From: Krzosa Karol Date: Tue, 2 Jul 2024 11:09:20 +0200 Subject: [PATCH] Fix scrolling --- src/text_editor/main.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/text_editor/main.cpp b/src/text_editor/main.cpp index 2605fd5..3e3b6af 100644 --- a/src/text_editor/main.cpp +++ b/src/text_editor/main.cpp @@ -493,7 +493,6 @@ int main() { if (!window.mouse_selecting_hori_bar && !window.mouse_selecting_vert_bar) { bool mouse_in_window = CheckCollisionPointRec(mouse, ToRectangle(window.rect)) || CheckCollisionPointRec(mouse, ToRectangle(line_number_rect)); - // @todo: fix scrolling bug when selecting on left outside the frame!! if (!window.mouse_selecting && mouse_in_window) { SetMouseCursor(MOUSE_CURSOR_IBEAM); } @@ -503,10 +502,11 @@ int main() { } if ((mouse_in_window && IsMouseButtonDown(MOUSE_BUTTON_LEFT)) || window.mouse_selecting) { - Vec2 mouse_lookup = mouse - window.rect.min + window.scroll; - LayoutRow *row = GetLayoutRow(window, mouse_lookup.y); + Vec2 mouse_lookup = mouse - window.rect.min + window.scroll; + Vec2 mouse_in_text = mouse - window.rect.min; + LayoutRow *row = GetLayoutRow(window, mouse_lookup.y); if (row == NULL) { - if (mouse.y < 0) { + if (mouse_in_text.y < 0) { row = window.layout.rows.first(); } else { row = window.layout.rows.last(); @@ -516,7 +516,7 @@ int main() { LayoutColumn *col = GetLayoutColumn(row, mouse_lookup.x); if (col == NULL) { - if (mouse.x < 0) { + if (mouse_in_text.x < 0) { col = row->columns.first(); } else { col = row->columns.last();