本文整理汇总了Java中com.badlogic.gdx.scenes.scene2d.ui.TextField.addListener方法的典型用法代码示例。如果您正苦于以下问题:Java TextField.addListener方法的具体用法?Java TextField.addListener怎么用?Java TextField.addListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.scenes.scene2d.ui.TextField
的用法示例。
在下文中一共展示了TextField.addListener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTextField
import com.badlogic.gdx.scenes.scene2d.ui.TextField; //导入方法依赖的package包/类
private TextField getTextField(VisualSettingManager visualSettingManager) {
final TextField textField = new TextField(i + "", visualSettingManager.getSkin());
textField.addListener(new EventListener() {
@Override
public boolean handle(Event event) {
if (!(event instanceof SettingsMenu.SaveEvent)) return false;
try {
int n = Integer.parseInt(textField.getText());
if (hasRange && (n < rangeStart || n > rangeEnd)) {
throw new NumberFormatException();
} else {
set(n);
return true;
}
} catch (Exception e) {
textField.setText(i + "");
return false;
}
}
});
textField.setTextFieldFilter(new TextField.TextFieldFilter.DigitsOnlyFilter());
if (hasRange) textField.setMessageText("(" + rangeStart + "-" + rangeEnd + ")");
return textField;
}
示例2: createButton
import com.badlogic.gdx.scenes.scene2d.ui.TextField; //导入方法依赖的package包/类
private void createButton() {
Skin skin = getGameObject().getComponentInParent(JCanvas.class).getSkin();
// TextFieldStyle style = new TextFieldStyle(skin.get("default", TextFieldStyle.class));
int realSize = (int) (((getTransform().getScale().x + getTransform().getScale().y) / 2) * fontSize);
SmartFontGenerator fontGen = new SmartFontGenerator();
FileHandle exoFile = Gdx.files.internal(fontResource.getResourcePath());
BitmapFont fontBitmap = fontGen.createFont(exoFile, fontResource.getResourcePath() + realSize, realSize);
TextFieldStyle styleDefault = skin.get("default", TextFieldStyle.class);
TextFieldStyle style = new TextFieldStyle(fontBitmap, fontColor, styleDefault.cursor, styleDefault.selection, styleDefault.background);
style.fontColor = fontColor;
textField = new TextField(text, style);
textField.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
text = textField.getText();
}
});
}
示例3: addEntry
import com.badlogic.gdx.scenes.scene2d.ui.TextField; //导入方法依赖的package包/类
public void addEntry(final String name, int width) {
final TextField textField = new TextField("", getSkin());
nameToTextField.put(name, textField);
add(new Label(name, getSkin())).fill().left();
if (width != -1) {
add(textField).fill().right().width(width);
} else {
add(textField).fill().right();
}
textField.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
if (listener != null) {
listener.onChange(name, textField.getText());
}
}
});
row();
pack();
}
示例4: SaveAsDialog
import com.badlogic.gdx.scenes.scene2d.ui.TextField; //导入方法依赖的package包/类
public SaveAsDialog(Skin skin) {
super("save as..", skin);
getContentTable().pad(15);
Label nameLabel = new Label("Name:", skin);
getContentTable().add(nameLabel);
final TextField textField = new TextField("", skin);
textField.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
resultValue = textField.getText();
}
});
getContentTable().add(textField);
button("save", true);
button("cancel", false);
pack();
}
示例5: buildSearchButton
import com.badlogic.gdx.scenes.scene2d.ui.TextField; //导入方法依赖的package包/类
protected LinearLayout buildSearchButton() {
LinearLayout searchActor = new LinearLayout(true);
IconButton icon = WidgetBuilder.toolbarIcon(SkinConstants.IC_SEARCH,
i18N.m("search"));
search = new TextField("", skin);
search.addListener(new InputListener() {
@Override
public boolean keyUp(InputEvent event, int keycode) {
if (keycode == Input.Keys.ENTER) {
loadContents();
return true;
}
return false;
}
});
searchActor.add(icon);
searchActor.add(search).marginRight(WidgetBuilder.dpToPixels(16));
return searchActor;
}
示例6: getActor
import com.badlogic.gdx.scenes.scene2d.ui.TextField; //导入方法依赖的package包/类
@Override
public Actor getActor(VisualSettingManager visualSettingManager) {
final TextField textField = new TextField(s, visualSettingManager.getSkin());
textField.addListener(new EventListener() {
@Override
public boolean handle(Event event) {
if (!(event instanceof SettingsMenu.SaveEvent))
return false;
set(textField.getText());
return true;
}
});
return textField;
}
示例7: ConsoleDialog
import com.badlogic.gdx.scenes.scene2d.ui.TextField; //导入方法依赖的package包/类
public ConsoleDialog(UserInterface linkedInterface)
{
super("Console", Settings.DEFAULT_SKIN);
this.linkedInterface = linkedInterface;
setBounds(400, 700, 600, 150);
Button closeButton = new CloseButton(this);
getTitleTable().add(closeButton).size(15, 15).padRight(-5).top().right();
Table table = getContentTable();
inputTextField = new TextField("", getSkin());
inputTextField.addListener(new InputListener(){
@Override
public boolean keyDown(InputEvent event, int keycode)
{
if(!ConsoleDialog.this.isVisible())
inputTextField.setDisabled(true);
if(keycode == Keys.ENTER)
{
addMessageToList();
sendCommandToExecute();
}
return false;
}
});
consolePane = new ConsolePane();
table.add(consolePane).fillX();
table.row();
table.add(inputTextField).width(570).align(Align.bottom);
table.align(Align.bottom);
}
示例8: ChatDialog
import com.badlogic.gdx.scenes.scene2d.ui.TextField; //导入方法依赖的package包/类
public ChatDialog(UserInterface linkedInterface)
{
super("Chat", Settings.DEFAULT_SKIN);
this.linkedInterface = linkedInterface;
setBounds(0, 0, 400, 200);
Button closeButton = new CloseButton(this);
getTitleTable().add(closeButton).size(15, 15).padRight(-5).top().right();
Table table = getContentTable();
chatTextField = new TextField("", getSkin());
chatTextField.addListener(new InputListener(){
@Override
public boolean keyDown(InputEvent event, int keycode)
{
if(!ChatDialog.this.isVisible())
chatTextField.setDisabled(true);
if(keycode == Keys.ENTER)
sendMessage();
return false;
}
});
chatPane = new ChatPane();
table.add(chatPane).fillX();
table.row();
table.add(chatTextField).fillX().align(Align.bottom);
table.align(Align.bottom);
}
示例9: getActor
import com.badlogic.gdx.scenes.scene2d.ui.TextField; //导入方法依赖的package包/类
@Override
public Actor getActor(VisualSettingManager visualSettingManager) {
final TextField textField = new TextField(s, visualSettingManager.getSkin());
textField.addListener(new EventListener() {
@Override
public boolean handle(Event event) {
if (!(event instanceof SettingsMenu.SaveEvent)) return false;
set(textField.getText());
return true;
}
});
return textField;
}
示例10: InputDialog
import com.badlogic.gdx.scenes.scene2d.ui.TextField; //导入方法依赖的package包/类
public InputDialog(String title, String message, InputDialogStyle style, OkCancelCallback<String> callback) {
super(title, style);
this.callback = callback;
messageLabel = new Label(message, style.messageStyle);
messageLabel.setWrap(true);
textField = new TextField("", style.textFieldStyle);
textField.addListener(new InputListener() {
@Override
public boolean keyUp(InputEvent event, int keycode) {
if (KeyBindings.CONFIRM.is(keycode)) {
if (textField.getText().trim().length() < 1) {
return false;
}
okButton.toggle();
return true;
} else if (KeyBindings.CANCEL.is(keycode)) {
cancelButton.toggle();
}
return false;
}
});
add(messageLabel).fill().width(style.messageWidth);
row();
add(textField).fill().width(style.messageWidth).padTop(style.textFieldMarginTop);
row();
Table buttonsTable = new Table();
createButtons(buttonsTable, style);
add(buttonsTable).center().padTop(style.buttonsMarginTop);
pack();
}
示例11: RenameDialog
import com.badlogic.gdx.scenes.scene2d.ui.TextField; //导入方法依赖的package包/类
public RenameDialog(Skin skin, String oldName) {
super("Rename", skin);
getContentTable().defaults().pad(14);
final TextField renameTextField = new TextField(oldName, skin);
renameTextField.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
resultValue = renameTextField.getText();
}
});
getContentTable().add(renameTextField);
button("OK", true);
button("cancel", false);
}
示例12: CommandLineService
import com.badlogic.gdx.scenes.scene2d.ui.TextField; //导入方法依赖的package包/类
public CommandLineService(ConsoleView consoleView, TextField inputField, JsScriptManager scriptManager, AliasManager aliasManager) {
this.consoleView = consoleView;
this.inputField = inputField;
this.scriptManager = scriptManager;
this.aliasManager = aliasManager;
history = new CommandHistory();
inputField.addListener(new KeyListener());
}
示例13: RoomChatPanel
import com.badlogic.gdx.scenes.scene2d.ui.TextField; //导入方法依赖的package包/类
public RoomChatPanel (float w, float h) {
super();
content = new StringBuilder();
chatprint= new Label(content,Resources._skin);
inputfield = new TextField("",Resources._skin);
inputfield.setWidth(w);
inputfield.setMaxLength(max_char_per_mess);
inputfield.setMessageText("Enter to send ...");
inputfield.addListener(new InputListener() {
RoomChat__ chat = new RoomChat__();
public boolean keyTyped(InputEvent event, char character) {
if ( character == 13) {
chat.content = inputfield.getText().getBytes();
Resources._nclient.sendRoomChat(chat);
inputfield.setText("");
}
return false;
};
} );
scrpane = new ScrollPane(chatprint, Resources._skin);
scrpane.setSize(w,h-inputfield.getHeight()-1);
scrpane.setFadeScrollBars(false);
scrpane.setPosition(0,inputfield.getHeight()+1);
addActor(scrpane);
addActor(inputfield);
this.h = h;
this.w = w;
}
示例14: FilesListWidget
import com.badlogic.gdx.scenes.scene2d.ui.TextField; //导入方法依赖的package包/类
public FilesListWidget(Skin skin) {
super(false);
style = skin.get(FilesListWidgetStyle.class);
folderStyle = new FileIconWidgetStyle(style.folderIcon, style.font,
style.fontColor, style.selected, style.over);
fileStyle = new FileIconWidgetStyle(style.fileIcon, style.font,
style.fontColor, style.selected, style.over);
filesContainer = new Group();
ScrollPaneStyle scrollStyle = skin.get(ScrollPaneStyle.class);
scrollPane = new ScrollPane(filesContainer, scrollStyle);
scrollPane.setFlickScroll(false);
scrollPane.setFlingTime(0);
scrollPane.setSmoothScrolling(false);
currentPath = new TextField("", skin);
currentPath.addListener(new InputListener() {
@Override
public boolean keyDown(InputEvent event, int keycode) {
switch (keycode) {
case Keys.ENTER:
String path = currentPath.getText();
FileHandle fileHandle = Gdx.files.absolute(path);
if (fileHandle.exists()) {
setSelectedFile(fileHandle, true);
}
return true;
}
return false;
}
});
add(currentPath).expandX();
add(scrollPane).expand(true, true);
}
示例15: DialogCustomProperty
import com.badlogic.gdx.scenes.scene2d.ui.TextField; //导入方法依赖的package包/类
public DialogCustomProperty(Main main, String title, String propertyName, PropertyType propertyType, boolean allowSameName) {
super(title, main.getSkin(), "bg");
this.allowSameName = allowSameName;
oldName = propertyName;
getTitleLabel().setAlignment(Align.center);
this.main = main;
Label label = new Label("What is the property name?", getSkin());
getContentTable().add(label).pad(10.0f).padBottom(0.0f);
getContentTable().row();
label = new Label("(ex. up)", getSkin());
getContentTable().add(label).pad(10.0f).padTop(0.0f).padBottom(5.0f);
getContentTable().row();
nameField = new TextField("", getSkin());
nameField.setFocusTraversal(false);
nameField.setText(propertyName);
nameField.selectAll();
nameField.addListener(main.getIbeamListener());
getContentTable().add(nameField).growX().padLeft(10.0f).padRight(10.0f);
getContentTable().row();
label = new Label("What is the property type?", getSkin());
getContentTable().add(label).pad(10.0f).padBottom(5.0f);
getContentTable().row();
propertyTypeBox = new SelectBox<>(getSkin());
propertyTypeBox.setItems(PropertyType.TEXT, PropertyType.RAW_TEXT, PropertyType.NUMBER, PropertyType.BOOL, PropertyType.FONT, PropertyType.DRAWABLE, PropertyType.COLOR);
propertyTypeBox.addListener(main.getHandListener());
propertyTypeBox.getList().addListener(main.getHandListener());
if (propertyType != null && propertyType != PropertyType.NONE) {
propertyTypeBox.setSelected(propertyType);
}
getContentTable().add(propertyTypeBox).growX().padLeft(10.0f).padRight(10.0f);
getButtonTable().defaults().padBottom(10.0f).minWidth(50.0f);
button("OK", true).key(Keys.ENTER, true);
button("Cancel", false).key(Keys.ESCAPE, false);
okButton = (TextButton) getButtonTable().getCells().first().getActor();
updateOkButton();
getButtonTable().getCells().get(1).getActor().addListener(main.getHandListener());
nameField.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
updateOkButton();
}
});
}