diff options
author | nea <romangraef@gmail.com> | 2021-11-12 23:28:49 +0100 |
---|---|---|
committer | nea <romangraef@gmail.com> | 2021-11-12 23:28:49 +0100 |
commit | b248b4744ae2038fbeb5ded0a03ce641cdbed26e (patch) | |
tree | bac6e9e90cfee1162c9ba188e9efb19992b3967f | |
parent | 56f354e4f764458a79ef5df02115160cf7d3ff30 (diff) | |
download | LibGui-feature/improvetextfield.tar.gz LibGui-feature/improvetextfield.tar.bz2 LibGui-feature/improvetextfield.zip |
Revert breaking API changes in WTextFieldfeature/improvetextfield
-rw-r--r-- | src/main/java/io/github/cottonmc/cotton/gui/widget/WTextField.java | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WTextField.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WTextField.java index c290124..ed07f0b 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WTextField.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WTextField.java @@ -33,6 +33,12 @@ import java.util.function.Consumer; import java.util.function.Predicate; public class WTextField extends WWidget { + /** + * Use TEXT_PADDING_X instead. + */ + @Deprecated(forRemoval = true) + public static final int OFFSET_X_TEXT = 4; + public static final int TEXT_PADDING_X = 4; public static final int TEXT_PADDING_Y = 6; public static final int CURSOR_PADDING_Y = 4; @@ -504,7 +510,7 @@ public class WTextField extends WWidget { * @return */ @Environment(EnvType.CLIENT) - @Deprecated + @Deprecated(forRemoval = true) public static int getCaretPos(String s, int x) { if (x <= 0) return 0; @@ -520,4 +526,21 @@ public class WTextField extends WWidget { return s.length(); } + + /** + * From a caret position, finds out what the x-offset to draw the caret is. + * @param s + * @param pos + * @return + */ + @Environment(EnvType.CLIENT) + @Deprecated(forRemoval = true) + public static int getCaretOffset(String s, int pos) { + if (pos==0) return 0;//-1; + + TextRenderer font = MinecraftClient.getInstance().textRenderer; + int ofs = font.getWidth(s.substring(0, pos))+1; + return ofs; //(font.isRightToLeft()) ? -ofs : ofs; + } + } |