ChatboxTextInput: Don't divide by zero when clicking on an empty string
This commit is contained in:
@@ -318,6 +318,11 @@ public class ChatboxTextInput extends ChatboxInput implements KeyListener, Mouse
|
|||||||
isInBounds = ev -> bounds.contains(ev.getPoint());
|
isInBounds = ev -> bounds.contains(ev.getPoint());
|
||||||
getCharOffset = ev ->
|
getCharOffset = ev ->
|
||||||
{
|
{
|
||||||
|
if (fullWidth <= 0)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int cx = ev.getX() - canvasX;
|
int cx = ev.getX() - canvasX;
|
||||||
|
|
||||||
int charIndex = (tsValue.length() * cx) / fullWidth;
|
int charIndex = (tsValue.length() * cx) / fullWidth;
|
||||||
|
|||||||
Reference in New Issue
Block a user