本文整理汇总了Java中com.badlogic.gdx.scenes.scene2d.ui.TextField.TextFieldListener类的典型用法代码示例。如果您正苦于以下问题:Java TextFieldListener类的具体用法?Java TextFieldListener怎么用?Java TextFieldListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TextFieldListener类属于com.badlogic.gdx.scenes.scene2d.ui.TextField包,在下文中一共展示了TextFieldListener类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: process
import com.badlogic.gdx.scenes.scene2d.ui.TextField.TextFieldListener; //导入依赖的package包/类
@Override
public void process(final LmlParser parser, final LmlTag tag, final TextField actor,
final String rawAttributeData) {
final ActorConsumer<?, Character> listener = parser.parseAction(rawAttributeData, Character.valueOf(' '));
if (listener == null) {
parser.throwErrorIfStrict(
"Text field listener attribute requires ID of an action that consumes a Character. Valid action not found for name: "
+ rawAttributeData);
return;
}
actor.setTextFieldListener(new TextFieldListener() {
@Override
public void keyTyped(final TextField textField, final char character) {
listener.consume(character);
}
});
}
示例2: addTextField
import com.badlogic.gdx.scenes.scene2d.ui.TextField.TextFieldListener; //导入依赖的package包/类
public void addTextField(String label, Object value, TextFieldListener lis) {
Label l = new Label(label, skin.get(LabelStyle.class));
table.add(l).minHeight(l.getMinHeight()).prefHeight(l.getPrefHeight());
TextField t = new TextField(String.valueOf(value), skin.get(TextFieldStyle.class));
t.setTextFieldListener(lis);
t.setDisabled(false);
t.setMaxLength(6);
if (value instanceof Number)
t.setTextFieldFilter((textField, c) -> Character.isDigit(c));
table.add(t).right().padLeft(1f);
table.row();
}
示例3: FileChooser
import com.badlogic.gdx.scenes.scene2d.ui.TextField.TextFieldListener; //导入依赖的package包/类
public FileChooser(String title, final Skin skin, FileHandle baseDir) {
super(title, skin);
this.skin = skin;
this.baseDir = baseDir;
final Table content = getContentTable();
content.top().left();
fileListLabel = new Label("", skin);
fileListLabel.setAlignment(Align.left);
fileList = new List<FileListItem>(skin, "light");
fileList.getSelection().setProgrammaticChangeEvents(false);
fileNameInput = new TextField("", skin);
fileNameLabel = new Label("File name:", skin);
fileNameInput.setTextFieldListener(new TextFieldListener() {
@Override
public void keyTyped(TextField textField, char c) {
result = textField.getText();
}
});
ok = new TextButton("Ok", skin);
button(ok, true);
cancel = new TextButton("Cancel", skin);
button(cancel, false);
key(Keys.ENTER, true);
key(Keys.ESCAPE, false);
fileList.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
final FileListItem selected = fileList.getSelected();
result = selected.name;
fileNameInput.setText(result);
}
});
}