当前位置: 首页>>代码示例>>Java>>正文


Java TextField.setTextFieldListener方法代码示例

本文整理汇总了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);
        }
    });
}
 
开发者ID:czyzby,项目名称:gdx-lml,代码行数:18,代码来源:TextFieldListenerLmlAttribute.java

示例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();
}
 
开发者ID:guillaume-alvarez,项目名称:ShapeOfThingsThatWere,代码行数:15,代码来源:FramedMenu.java

示例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);
        }
    });
}
 
开发者ID:langurmonkey,项目名称:gaiasky,代码行数:41,代码来源:FileChooser.java

示例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);
}
 
开发者ID:raeleus,项目名称:skin-composer,代码行数:64,代码来源:DialogFactory.java

示例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);
}
 
开发者ID:raeleus,项目名称:skin-composer,代码行数:67,代码来源:DialogFactory.java

示例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);
}
 
开发者ID:raeleus,项目名称:skin-composer,代码行数:65,代码来源:DialogFactory.java

示例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++;
}
 
开发者ID:MJacred,项目名称:amidakuji,代码行数:43,代码来源:UIMenuBuild.java


注:本文中的com.badlogic.gdx.scenes.scene2d.ui.TextField.setTextFieldListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。