fix textinput color on string change
This commit is contained in:
parent
42804cfe3c
commit
726ffe065e
@ -46,6 +46,7 @@ public class TextInput implements DrawableElement, FocusableElement, KeyEventEle
|
|||||||
FocusEventCallback onFocusCallback;
|
FocusEventCallback onFocusCallback;
|
||||||
FocusEventCallback onLoseFocusCallback;
|
FocusEventCallback onLoseFocusCallback;
|
||||||
KeyboardEventCallback onKeyPressCallback;
|
KeyboardEventCallback onKeyPressCallback;
|
||||||
|
Vector3f color;
|
||||||
|
|
||||||
String text = "";
|
String text = "";
|
||||||
int textPixelWidth = 0;
|
int textPixelWidth = 0;
|
||||||
@ -60,6 +61,7 @@ public class TextInput implements DrawableElement, FocusableElement, KeyEventEle
|
|||||||
this.width = 0;
|
this.width = 0;
|
||||||
this.height = (int)(FontUtils.getFontHeight() * fontSize);
|
this.height = (int)(FontUtils.getFontHeight() * fontSize);
|
||||||
this.fontSize = fontSize;
|
this.fontSize = fontSize;
|
||||||
|
this.color = new Vector3f(1,1,1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void generateLetters(){
|
void generateLetters(){
|
||||||
@ -69,6 +71,7 @@ public class TextInput implements DrawableElement, FocusableElement, KeyEventEle
|
|||||||
char toDraw = text.charAt(i);
|
char toDraw = text.charAt(i);
|
||||||
Vector3f bitMapDimension = FontUtils.getDimensionOfCharacterDiscrete(toDraw);
|
Vector3f bitMapDimension = FontUtils.getDimensionOfCharacterDiscrete(toDraw);
|
||||||
BitmapCharacter newLetter = new BitmapCharacter((int)(rollingOffset * fontSize) + positionX, positionY, (int)(bitMapDimension.x * fontSize), this.height, toDraw);
|
BitmapCharacter newLetter = new BitmapCharacter((int)(rollingOffset * fontSize) + positionX, positionY, (int)(bitMapDimension.x * fontSize), this.height, toDraw);
|
||||||
|
newLetter.setColor(color);
|
||||||
rollingOffset += (int)bitMapDimension.x;
|
rollingOffset += (int)bitMapDimension.x;
|
||||||
childrenElements.add(newLetter);
|
childrenElements.add(newLetter);
|
||||||
}
|
}
|
||||||
@ -85,6 +88,7 @@ public class TextInput implements DrawableElement, FocusableElement, KeyEventEle
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setColor(Vector3f color){
|
public void setColor(Vector3f color){
|
||||||
|
this.color.set(color);
|
||||||
for(BitmapCharacter character : childrenElements){
|
for(BitmapCharacter character : childrenElements){
|
||||||
character.setColor(color);
|
character.setColor(color);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user