Fix scrolling

This commit is contained in:
Krzosa Karol
2024-07-02 11:09:20 +02:00
parent 8250058296
commit 0a75cde80c

View File

@@ -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();