本文整理汇总了Java中com.badlogic.gdx.scenes.scene2d.ui.TextField.setTextFieldListener方法的典型用法代码示例。如果您正苦于以下问题:Java TextField.setTextFieldListener方法的具体用法?Java TextField.setTextFieldListener怎么用?Java TextField.setTextFieldListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.scenes.scene2d.ui.TextField
的用法示例。
在下文中一共展示了TextField.setTextFieldListener方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: process
import com.badlogic.gdx.scenes.scene2d.ui.TextField; //导入方法依赖的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; //导入方法依赖的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; //导入方法依赖的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);
}
});
}
示例4: showNewStyleDialog
import com.badlogic.gdx.scenes.scene2d.ui.TextField; //导入方法依赖的package包/类
public void showNewStyleDialog(Skin skin, Stage stage) {
Class selectedClass = main.getRootTable().getSelectedClass();
final TextField textField = new TextField("", skin);
Dialog dialog = new Dialog("New Style", skin, "bg") {
@Override
protected void result(Object object) {
if ((Boolean) object) {
main.getUndoableManager().addUndoable(new NewStyleUndoable(selectedClass, textField.getText(), main), true);
}
}
};
dialog.getButtonTable().defaults().padBottom(10.0f).minWidth(50.0f);
dialog.button("OK", true).button("Cancel", false);
dialog.getButtonTable().getCells().first().getActor().addListener(main.getHandListener());
dialog.getButtonTable().getCells().get(1).getActor().addListener(main.getHandListener());
final TextButton okButton = (TextButton) dialog.getButtonTable().getCells().get(0).getActor();
textField.setTextFieldListener((TextField textField1, char c) -> {
if (c == '\n') {
if (!okButton.isDisabled()) {
main.getUndoableManager().addUndoable(new NewStyleUndoable(selectedClass, textField1.getText(), main), true);
dialog.hide();
}
main.getStage().setKeyboardFocus(textField1);
}
});
textField.addListener(main.getIbeamListener());
dialog.getTitleLabel().setAlignment(Align.center);
dialog.getContentTable().defaults().padLeft(10.0f).padRight(10.0f);
dialog.text("What is the name of the new style?");
dialog.getContentTable().getCells().first().pad(10.0f);
dialog.getContentTable().row();
dialog.getContentTable().add(textField).growX();
okButton.setDisabled(true);
Array<StyleData> currentStyles = main.getProjectData().getJsonData().getClassStyleMap().get(selectedClass);
textField.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
boolean disable = !StyleData.validate(textField.getText());
if (!disable) {
for (StyleData data : currentStyles) {
if (data.name.equals(textField.getText())) {
disable = true;
break;
}
}
}
okButton.setDisabled(disable);
}
});
dialog.key(Input.Keys.ESCAPE, false);
dialog.show(stage);
stage.setKeyboardFocus(textField);
textField.setFocusTraversal(false);
}
示例5: showDuplicateStyleDialog
import com.badlogic.gdx.scenes.scene2d.ui.TextField; //导入方法依赖的package包/类
public void showDuplicateStyleDialog(Skin skin, Stage stage) {
Class selectedClass = main.getRootTable().getSelectedClass();
StyleData originalStyle = main.getRootTable().getSelectedStyle();
final TextField textField = new TextField("", skin);
Dialog dialog = new Dialog("Duplicate Style", skin, "bg") {
@Override
protected void result(Object object) {
if ((Boolean) object) {
main.getUndoableManager().addUndoable(new DuplicateStyleUndoable(originalStyle, textField.getText(), main), true);
}
}
};
dialog.getButtonTable().defaults().padBottom(10.0f).minWidth(50.0f);
dialog.button("OK", true).button("Cancel", false);
final TextButton okButton = (TextButton) dialog.getButtonTable().getCells().get(0).getActor();
okButton.addListener(main.getHandListener());
dialog.getButtonTable().getCells().get(1).getActor().addListener(main.getHandListener());
textField.setTextFieldListener((TextField textField1, char c) -> {
if (c == '\n') {
if (!okButton.isDisabled()) {
main.getUndoableManager().addUndoable(new DuplicateStyleUndoable(originalStyle, textField.getText(), main), true);
dialog.hide();
}
main.getStage().setKeyboardFocus(textField1);
}
});
textField.addListener(main.getIbeamListener());
dialog.getTitleLabel().setAlignment(Align.center);
dialog.getContentTable().defaults().padLeft(10.0f).padRight(10.0f);
dialog.text("What is the name of the new, duplicated style?");
dialog.getContentTable().getCells().first().pad(10.0f);
dialog.getContentTable().row();
dialog.getContentTable().add(textField).growX();
okButton.setDisabled(true);
Array<StyleData> currentStyles = main.getProjectData().getJsonData().getClassStyleMap().get(selectedClass);
textField.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
boolean disable = !StyleData.validate(textField.getText());
if (!disable) {
for (StyleData data : currentStyles) {
if (data.name.equals(textField.getText())) {
disable = true;
break;
}
}
}
okButton.setDisabled(disable);
}
});
dialog.key(Input.Keys.ESCAPE, false);
dialog.show(stage);
stage.setKeyboardFocus(textField);
textField.setFocusTraversal(false);
}
示例6: showRenameStyleDialog
import com.badlogic.gdx.scenes.scene2d.ui.TextField; //导入方法依赖的package包/类
public void showRenameStyleDialog(Skin skin, Stage stage) {
Class selectedClass = main.getRootTable().getSelectedClass();
final TextField textField = new TextField(main.getRootTable().getSelectedStyle().name, skin);
Dialog dialog = new Dialog("Rename Style", skin, "bg") {
@Override
protected void result(Object object) {
if ((Boolean) object) {
main.getUndoableManager().addUndoable(new UndoableManager.RenameStyleUndoable(main.getRootTable().getSelectedStyle(), main, textField.getText()), true);
}
}
};
dialog.getButtonTable().defaults().padBottom(10.0f).minWidth(50.0f);
dialog.button("OK", true).button("Cancel", false);
dialog.getButtonTable().getCells().first().getActor().addListener(main.getHandListener());
dialog.getButtonTable().getCells().get(1).getActor().addListener(main.getHandListener());
final TextButton okButton = (TextButton) dialog.getButtonTable().getCells().get(0).getActor();
textField.setTextFieldListener((TextField textField1, char c) -> {
if (c == '\n') {
if (!okButton.isDisabled()) {
main.getUndoableManager().addUndoable(new UndoableManager.RenameStyleUndoable(main.getRootTable().getSelectedStyle(), main, textField1.getText()), true);
dialog.hide();
}
main.getStage().setKeyboardFocus(textField1);
}
});
textField.addListener(main.getIbeamListener());
dialog.getTitleLabel().setAlignment(Align.center);
dialog.getContentTable().defaults().padLeft(10.0f).padRight(10.0f);
dialog.text("What would you like to rename the style \"" + main.getRootTable().getSelectedStyle().name + "\" to?");
dialog.getContentTable().getCells().first().pad(10.0f);
dialog.getContentTable().row();
dialog.getContentTable().add(textField).growX();
okButton.setDisabled(true);
Array<StyleData> currentStyles = main.getProjectData().getJsonData().getClassStyleMap().get(selectedClass);
textField.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
boolean disable = !StyleData.validate(textField.getText());
if (!disable) {
for (StyleData data : currentStyles) {
if (data.name.equals(textField.getText())) {
disable = true;
break;
}
}
}
okButton.setDisabled(disable);
}
});
dialog.key(Input.Keys.ESCAPE, false);
dialog.show(stage);
stage.setKeyboardFocus(textField);
textField.selectAll();
textField.setFocusTraversal(false);
}
示例7: onNewInput
import com.badlogic.gdx.scenes.scene2d.ui.TextField; //导入方法依赖的package包/类
protected void onNewInput() {
// DESC-> ?
if(focusLost) {
return;
}
// ACT-> save top and bottom value
String tempTopText = textTop.getText().toUpperCase().trim();
String tempBottomText = textBottom.getText().toUpperCase().trim();
if(tempTopText.length() == 0
|| tempBottomText.length() == 0) {
// ACT-> if either top or bottom value is empty, abort method
return;
}
for(LogLine line: menuLines) {
if(line.getTop().getText().compareToIgnoreCase(tempTopText) == 0) {
// DESC-> top values have to be unique
// ACT-> abort action, if this input equals an older input (applies to top values only)
return;
}
}
TextField topValueTextField = new TextField(tempTopText, skin);
topValueTextField.setTextFieldListener(valueElementListener);
TextField bottomValueTextField = new TextField(tempBottomText, skin);
bottomValueTextField.setTextFieldListener(valueElementListener);
// DESC-> combination of top and bottom value (graphical elements: top value, bottom value, delete button)
LogLine tempLogLine = new LogLine(topValueTextField, bottomValueTextField, new ImageButton(drawableDeleteBtn));
menuLines.add(tempLogLine);
table.add(tempLogLine.getTop()).expandX().padLeft(15).fillX().left();
table.add(tempLogLine.getBottom()).expandX().padLeft(15 + 32).fillX().left();
table.add(tempLogLine.getDelete()).left().row();
countLevelValues++;
}