ChatboxTextInput: Don't divide by zero when clicking on an empty string

This commit is contained in:
Max Weber
2018-10-22 21:35:55 -06:00
parent a717d8027d
commit ff5290b5d1

View File

@@ -318,6 +318,11 @@ public class ChatboxTextInput extends ChatboxInput implements KeyListener, Mouse
isInBounds = ev -> bounds.contains(ev.getPoint());
getCharOffset = ev ->
{
if (fullWidth <= 0)
{
return 0;
}
int cx = ev.getX() - canvasX;
int charIndex = (tsValue.length() * cx) / fullWidth;