Skip to content

Commit d175902

Browse files
Fix EditText with caret
1 parent 445b8cb commit d175902

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

core/src/br/nullexcept/mux/widget/EditText.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,12 @@ public void onDraw(Canvas canvas) {
380380
canvas.translate(-getPaddingLeft(), -getPaddingTop());
381381
}
382382

383+
@Override
384+
public void onFocusChanged(boolean focused) {
385+
super.onFocusChanged(focused);
386+
invalidate();
387+
}
388+
383389
private class TextMeasureRenderer implements TextLayout.TextRenderer {
384390

385391
@Override public void drawSelection(Canvas canvas, int x, int y, int width, int height) {}
@@ -434,7 +440,9 @@ public void drawCharacter(Canvas canvas, char ch, int x, int y, int charIndex, i
434440
@Override
435441
public void drawCaret(Canvas canvas, int x, int y) {
436442
paintSelection.setColor(selectionColor.getColor());
437-
canvas.drawRect(x,y,x+(paint.getFontMetrics().measureChar('|')/4),y+paint.getFontMetrics().getLineHeight(),paintSelection);
443+
if (isFocused()) {
444+
canvas.drawRect(x, y, x + (paint.getFontMetrics().measureChar('|') / 4), y + paint.getFontMetrics().getLineHeight(), paintSelection);
445+
}
438446
}
439447
}
440448
}

0 commit comments

Comments
 (0)