Skip to content

Commit

Permalink
[scene2d.ui] Fixed TextField breaking if the font has markup enabled. (
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanSweet committed Apr 20, 2024
1 parent 10b21c0 commit 2849926
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions gdx/src/com/badlogic/gdx/scenes/scene2d/ui/TextField.java
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,12 @@ public void draw (Batch batch, float parentAlpha) {
drawMessageText(batch, messageFont, x + bgLeftWidth, y + textY + yOffset, width - bgLeftWidth - bgRightWidth);
}
} else {
BitmapFontData data = font.getData();
boolean markupEnabled = data.markupEnabled;
data.markupEnabled = false;
font.setColor(fontColor.r, fontColor.g, fontColor.b, fontColor.a * color.a * parentAlpha);
drawText(batch, font, x + bgLeftWidth, y + textY + yOffset);
data.markupEnabled = markupEnabled;
}
if (!disabled && cursorOn && cursorPatch != null) {
drawCursor(cursorPatch, batch, font, x + bgLeftWidth, y + textY);
Expand Down Expand Up @@ -418,7 +422,11 @@ void updateDisplayText () {
} else
displayText = newDisplayText;

boolean markupEnabled = data.markupEnabled;
data.markupEnabled = false;
layout.setText(font, displayText.toString().replace('\r', ' ').replace('\n', ' '));
data.markupEnabled = markupEnabled;

glyphPositions.clear();
float x = 0;
if (layout.runs.size > 0) {
Expand Down

0 comments on commit 2849926

Please sign in to comment.