Browse Source

Fix multiline TextInput when moving selection outside of TextInput (#1102)

Clamp selected line index
Casey Clyde 3 years ago
parent
commit
5548c47434
1 changed files with 1 additions and 0 deletions
  1. 1 0
      h2d/TextInput.hx

+ 1 - 0
h2d/TextInput.hx

@@ -457,6 +457,7 @@ class TextInput extends Text {
 		x += scrollX;
 		var lineIndex = Math.floor(y / font.lineHeight);
 		var lines = getAllLines();
+		lineIndex = hxd.Math.iclamp(lineIndex, 0, lines.length - 1);
 		var selectedLine = lines[lineIndex];
 		var pos = 0;
 		for(i in 0...lineIndex) {