v0.9.4: fixed a camera zoom error with text input
This commit is contained in:
parent
d03c80cb97
commit
87186c1426
|
@ -33,7 +33,7 @@ public class TextInput extends Component {
|
|||
|
||||
private NinePatch bg;
|
||||
|
||||
public TextInput( NinePatch bg, boolean multiline ){
|
||||
public TextInput( NinePatch bg, boolean multiline, int size ){
|
||||
super();
|
||||
this.bg = bg;
|
||||
add(bg);
|
||||
|
@ -52,10 +52,8 @@ public class TextInput extends Component {
|
|||
|
||||
skin = new Skin(FileUtils.getFileHandle(Files.FileType.Internal, "gdx/textfield.json"));
|
||||
|
||||
int zoom = (int) Camera.main.zoom;
|
||||
int textSize = multiline ? 6 : 9;
|
||||
TextField.TextFieldStyle style = skin.get(TextField.TextFieldStyle.class);
|
||||
style.font = Game.platform.getFont(textSize*zoom, "", false, false);
|
||||
style.font = Game.platform.getFont(size, "", false, false);
|
||||
style.background = null;
|
||||
textField = multiline ? new TextArea("", style) : new TextField("", style);
|
||||
textField.setProgrammaticChangeEvents(true);
|
||||
|
@ -65,7 +63,7 @@ public class TextInput extends Component {
|
|||
textField.addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
BitmapFont f = Game.platform.getFont(textSize*zoom, textField.getText(), false, false);
|
||||
BitmapFont f = Game.platform.getFont(size, textField.getText(), false, false);
|
||||
TextField.TextFieldStyle style = textField.getStyle();
|
||||
if (f != style.font){
|
||||
style.font = f;
|
||||
|
|
|
@ -38,7 +38,8 @@ public class WndTextInput extends Window {
|
|||
txtTitle.setPos((width - txtTitle.width()) / 2, 2);
|
||||
add(txtTitle);
|
||||
|
||||
TextInput textBox = new TextInput(Chrome.get(Chrome.Type.TOAST_WHITE), multiLine);
|
||||
int textSize = (int)PixelScene.uiCamera.zoom * (multiLine ? 6 : 9);
|
||||
TextInput textBox = new TextInput(Chrome.get(Chrome.Type.TOAST_WHITE), multiLine, textSize);
|
||||
if (initialValue != null) textBox.setText(initialValue);
|
||||
textBox.setMaxLength(maxLength);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user