Skip to content
Snippets Groups Projects
Commit 3bced07f authored by Luboš Horáček's avatar Luboš Horáček
Browse files

#22 Text input on android

parent 5237d9d4
Branches
Tags
No related merge requests found
......@@ -13,7 +13,7 @@ import cz.nic.tablexia.game.GameDefinition;
import cz.nic.tablexia.game.difficulty.GameDifficulty;
import cz.nic.tablexia.loader.application.ApplicationTextManager;
import cz.nic.tablexia.screen.AbstractTablexiaScreen;
import cz.nic.tablexia.screen.gamemenu.GameMenuScreen;
import cz.nic.tablexia.screen.createuser.FormScreen;
import cz.nic.tablexia.util.Log;
import cz.nic.tablexia.util.Utility;
......@@ -24,7 +24,7 @@ public class TablexiaSettings {
private static final int MIN_SCREEN_HEIGHT = (int) (DEFAULT_SCREEN_WIDTH * MAXIMUM_RATIO);
private static final boolean DEBUG_SHOW_BOUNDING_BOXES = true;
public static final Class<? extends AbstractTablexiaScreen<?>> INITIAL_SCREEN = GameMenuScreen.class;
public static final Class<? extends AbstractTablexiaScreen<?>> INITIAL_SCREEN = FormScreen.class;
public static final String LOCALE_KEY = "locale";
public static final String CURRENT_SCREEN_KEY = "current_screen";
......
......@@ -27,6 +27,7 @@ public class FormScreen extends AbstractAutoloadTablexiaScreen<Void> {
private Label ageLabel, nameLabel;
private int age;
private String name;
private String mugshot;
private User user = new User();
......@@ -74,12 +75,15 @@ public class FormScreen extends AbstractAutoloadTablexiaScreen<Void> {
ageLabel.setPosition(getStage().getWidth() * 0.58f, getStage().getWidth() * 0.185f);
age.setPosition(getStage().getWidth() * 0.58f, getStage().getWidth() * 0.225f);
gender.setPosition(getStage().getWidth() * 0.73f, getStage().getWidth() * 0.225f);
nameLabel.addListener(new FormInputListener(nameLabel));
nameLabel.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
Gdx.input.setOnscreenKeyboardVisible(true);
// TODO input listener for writing
getStage().setKeyboardFocus(nameLabel);
}
});
......@@ -98,7 +102,7 @@ public class FormScreen extends AbstractAutoloadTablexiaScreen<Void> {
setAge(Math.min(FormScreen.this.age + 1, 99));
}
});
buttonMinus.addListener(new ClickListener(){
buttonMinus.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
setAge(Math.max(FormScreen.this.age - 1, 1));
......@@ -141,7 +145,10 @@ public class FormScreen extends AbstractAutoloadTablexiaScreen<Void> {
stamp.addListener(new DragActorListener(stamp, true));
getStage().addActor(group);
getStage().addListener(new FormInputListener(nameLabel));
Group mugshots = new Group();
}
private Label.LabelStyle getLabelStyle() {
......@@ -154,8 +161,7 @@ public class FormScreen extends AbstractAutoloadTablexiaScreen<Void> {
class StampStack extends Stack {
public StampStack(float width) {
// TODO position dependet images
// TODO position dependet images
}
}
}
......
package cz.nic.tablexia.screen.createuser.form;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.InputListener;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
......@@ -7,7 +8,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Label;
/**
* Created by lhoracek on 4/16/15.
*/
public class FormInputListener extends InputListener{
public class FormInputListener extends InputListener {
private final Label label;
......@@ -18,6 +19,10 @@ public class FormInputListener extends InputListener{
@Override
public boolean keyTyped(InputEvent event, char character) {
if (character == Input.Keys.ENTER || character == Input.Keys.TAB) {
label.getStage().unfocus(label);
return false;
}
label.getText().append(character);
label.invalidateHierarchy();
return true;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment