mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 18:58:00 +00:00
Fix selection logic for text fields
This commit is contained in:
@@ -2,6 +2,7 @@ package forge.toolbox;
|
|||||||
|
|
||||||
import com.badlogic.gdx.Input.Keys;
|
import com.badlogic.gdx.Input.Keys;
|
||||||
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;
|
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;
|
||||||
|
import com.badlogic.gdx.graphics.g2d.BitmapFont.TextBounds;
|
||||||
|
|
||||||
import forge.Forge;
|
import forge.Forge;
|
||||||
import forge.Forge.Graphics;
|
import forge.Forge.Graphics;
|
||||||
@@ -290,6 +291,18 @@ public class FTextField extends FDisplayObject implements ITextField {
|
|||||||
float h = getHeight();
|
float h = getHeight();
|
||||||
g.fillRect(BACK_COLOR, 0, 0, w, h);
|
g.fillRect(BACK_COLOR, 0, 0, w, h);
|
||||||
|
|
||||||
|
//determine actual rendered font so selection logic is accurate
|
||||||
|
TextBounds textBounds = font.getMultiLineBounds(text);
|
||||||
|
while (textBounds.width > w || textBounds.height > h) {
|
||||||
|
if (font.canShrink()) { //shrink font to fit if possible
|
||||||
|
font = font.shrink();
|
||||||
|
textBounds = font.getMultiLineBounds(text);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//draw selection if key input is active
|
//draw selection if key input is active
|
||||||
if (isEditing) {
|
if (isEditing) {
|
||||||
float selLeft = PADDING;
|
float selLeft = PADDING;
|
||||||
|
|||||||
Reference in New Issue
Block a user