From 726ffe065e16a64b16856aa12f6b3c8f4b72f6f7 Mon Sep 17 00:00:00 2001 From: austin Date: Sun, 15 May 2022 18:36:07 -0400 Subject: [PATCH] fix textinput color on string change --- .../java/electrosphere/renderer/ui/elements/TextInput.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/electrosphere/renderer/ui/elements/TextInput.java b/src/main/java/electrosphere/renderer/ui/elements/TextInput.java index 7951d800..6384ad6e 100644 --- a/src/main/java/electrosphere/renderer/ui/elements/TextInput.java +++ b/src/main/java/electrosphere/renderer/ui/elements/TextInput.java @@ -46,6 +46,7 @@ public class TextInput implements DrawableElement, FocusableElement, KeyEventEle FocusEventCallback onFocusCallback; FocusEventCallback onLoseFocusCallback; KeyboardEventCallback onKeyPressCallback; + Vector3f color; String text = ""; int textPixelWidth = 0; @@ -60,6 +61,7 @@ public class TextInput implements DrawableElement, FocusableElement, KeyEventEle this.width = 0; this.height = (int)(FontUtils.getFontHeight() * fontSize); this.fontSize = fontSize; + this.color = new Vector3f(1,1,1); } void generateLetters(){ @@ -69,6 +71,7 @@ public class TextInput implements DrawableElement, FocusableElement, KeyEventEle char toDraw = text.charAt(i); Vector3f bitMapDimension = FontUtils.getDimensionOfCharacterDiscrete(toDraw); BitmapCharacter newLetter = new BitmapCharacter((int)(rollingOffset * fontSize) + positionX, positionY, (int)(bitMapDimension.x * fontSize), this.height, toDraw); + newLetter.setColor(color); rollingOffset += (int)bitMapDimension.x; childrenElements.add(newLetter); } @@ -85,6 +88,7 @@ public class TextInput implements DrawableElement, FocusableElement, KeyEventEle } public void setColor(Vector3f color){ + this.color.set(color); for(BitmapCharacter character : childrenElements){ character.setColor(color); }