Skip to content

Commit 2a830de

Browse files
committed
Better selection and cursor size.
Before commit: ![](http://i.imgur.com/9gLpbdg.png) After: ![](http://i.imgur.com/yEJ1bzC.png) For an older skin using the "includePaddingInMetrics" method from the blog, I had to use this to get previous behavior: ``` protected void drawSelection (Drawable selection, Batch batch, BitmapFont font, float x, float y) { float adjust = font.getDescent() / 2; textHeight += adjust; super.drawSelection(selection, batch, font, x, y + adjust); textHeight -= adjust; } protected void drawCursor (Drawable cursorPatch, Batch batch, BitmapFont font, float x, float y) { float adjust = font.getDescent() / 2; textHeight += adjust; super.drawCursor(cursorPatch, batch, font, x, y + adjust); textHeight -= adjust; } ```
1 parent b65dd66 commit 2a830de

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

gdx/src/com/badlogic/gdx/scenes/scene2d/ui/TextField.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ protected float getTextY (BitmapFont font, Drawable background) {
336336
/** Draws selection rectangle **/
337337
protected void drawSelection (Drawable selection, Batch batch, BitmapFont font, float x, float y) {
338338
selection.draw(batch, x + selectionX + renderOffset + fontOffset, y - textHeight - font.getDescent(), selectionWidth,
339-
textHeight + font.getDescent() / 2);
339+
textHeight);
340340
}
341341

342342
protected void drawText (Batch batch, BitmapFont font, float x, float y) {
@@ -345,8 +345,7 @@ protected void drawText (Batch batch, BitmapFont font, float x, float y) {
345345

346346
protected void drawCursor (Drawable cursorPatch, Batch batch, BitmapFont font, float x, float y) {
347347
cursorPatch.draw(batch, x + textOffset + glyphPositions.get(cursor) - glyphPositions.get(visibleTextStart) + fontOffset
348-
+ font.getData().cursorX, y - textHeight - font.getDescent(), cursorPatch.getMinWidth(), textHeight + font.getDescent()
349-
/ 2);
348+
+ font.getData().cursorX, y - textHeight - font.getDescent(), cursorPatch.getMinWidth(), textHeight);
350349
}
351350

352351
void updateDisplayText () {

0 commit comments

Comments
 (0)