}
}
@Override
public void draw (SpriteBatch batch, float parentAlpha) {
final BitmapFont font = style.font;
final Color fontColor = style.fontColor;
final TextureRegion selection = style.selection;
final NinePatch cursorPatch = style.cursor;
batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);
float bgLeftWidth = 0;
if (style.background != null) {
style.background.draw(batch, x, y, width, height);
bgLeftWidth = style.background.getLeftWidth();
}
float textY = (int)(height / 2 + textBounds.height / 2 + font.getDescent());
calculateOffsets();
boolean focused = stage != null && stage.getKeyboardFocus() == this;
if (focused && hasSelection && selection != null) {
batch.draw(selection, x + selectionX + bgLeftWidth + renderOffset,
y + textY - textBounds.height - font.getDescent() / 2, selectionWidth, textBounds.height);
}
if (displayText.length() == 0) {
if (!focused && messageText != null) {
if (style.messageFontColor != null) {
font.setColor(style.messageFontColor.r, style.messageFontColor.g, style.messageFontColor.b,
style.messageFontColor.a * parentAlpha);
} else
font.setColor(0.7f, 0.7f, 0.7f, parentAlpha);
BitmapFont messageFont = style.messageFont != null ? style.messageFont : font;
font.draw(batch, messageText, x + bgLeftWidth, y + textY);
}
} else {
font.setColor(fontColor.r, fontColor.g, fontColor.b, fontColor.a * parentAlpha);
font.draw(batch, displayText, x + bgLeftWidth + textOffset, y + textY, visibleTextStart, visibleTextEnd);