From 85daacbf87554af524943aa25ce5e94fdb645530 Mon Sep 17 00:00:00 2001 From: Anuken Date: Sun, 29 Sep 2024 12:30:33 -0400 Subject: [PATCH] TextArea selection fixes --- arc-core/src/arc/scene/ui/TextArea.java | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/arc-core/src/arc/scene/ui/TextArea.java b/arc-core/src/arc/scene/ui/TextArea.java index 8b7c32852..cccfc385c 100644 --- a/arc-core/src/arc/scene/ui/TextArea.java +++ b/arc-core/src/arc/scene/ui/TextArea.java @@ -1,16 +1,15 @@ package arc.scene.ui; -import arc.Core; -import arc.struct.IntSeq; -import arc.graphics.g2d.Font; -import arc.graphics.g2d.GlyphLayout; -import arc.input.KeyCode; -import arc.scene.Scene; -import arc.scene.event.InputEvent; -import arc.scene.event.InputListener; -import arc.scene.style.Drawable; -import arc.util.Align; -import arc.util.pooling.Pools; +import arc.*; +import arc.graphics.g2d.*; +import arc.input.*; +import arc.math.*; +import arc.scene.*; +import arc.scene.event.*; +import arc.scene.style.*; +import arc.struct.*; +import arc.util.*; +import arc.util.pooling.*; /** A multiple-line text input field, entirely based on {@link TextField} */ public class TextArea extends TextField{ @@ -358,6 +357,7 @@ protected void setCursorPosition(float x, float y){ cursorLine = (int)Math.floor((height - y) / font.getLineHeight()) + firstLineShowing; cursorLine = Math.max(0, Math.min(cursorLine, getLines() - 1)); + cursorLine = Mathf.clamp(cursorLine, firstLineShowing, firstLineShowing + linesShowing - 1); super.setCursorPosition(x, y); updateCurrentLine();