Java 类com.badlogic.gdx.scenes.scene2d.ui.TextField.TextFieldFilter 实例源码

项目:gdx-lml    文件:TextFieldFilterLmlAttribute.java   
@Override
public void process(final LmlParser parser, final LmlTag tag, final TextField actor,
        final String rawAttributeData) {
    @SuppressWarnings("unchecked") final ActorConsumer<Boolean, Character> filter = (ActorConsumer<Boolean, Character>) parser
            .parseAction(rawAttributeData, Character.valueOf(' '));
    if (filter == null) {
        parser.throwErrorIfStrict(
                "Text field filter attribute requires ID of an action that consumes a Character and returns a boolean or Boolean. Valid action not found for name: "
                        + rawAttributeData);
        return;
    }
    actor.setTextFieldFilter(new TextFieldFilter() {
        @Override
        public boolean acceptChar(final TextField textField, final char character) {
            return filter.consume(character);
        }
    });
}
项目:cocos2d-java    文件:GdxUIConsole.java   
@Override
protected void onInitUI() {
    Skin skin = GdxUISkin.instance().getDeafult();
    input = new TextField("", skin);

    ClickListener mClickListener = new ClickListener() {
        public boolean keyDown (InputEvent event, int keycode) {
            if(keycode == Keys.ENTER && !isHide()) {
                if(!handleCmdString(input.getText())) {
                    //clear input 
                    input.setText(null);
                }
            }
            return true;
        }
    };
    input.addCaptureListener(mClickListener);

    input.setTextFieldFilter(new TextFieldFilter() {
        @Override
        public boolean acceptChar(TextField textField, char c) {
            if(c == '`' || c == '~') {
                hide();
                return false;
            }
            return true;
        }
    });
    label = new Label("", skin);

    maxTmp = GdxUIConfig.instance().consoleMaxOutputLine;

    input.setSize(getUIWidth()/2, 32);
    input.setPosition(20, getUIHeight() * 0.25f);
    addUI(input);
    addUI(label);

    skin = null;
}
项目:gdx-lml    文件:DigitsOnlyLmlAttribute.java   
@Override
public void process(final LmlParser parser, final LmlTag tag, final TextField actor,
        final String rawAttributeData) {
    if (parser.parseBoolean(rawAttributeData, actor)) {
        actor.setTextFieldFilter(new TextFieldFilter.DigitsOnlyFilter());
    }
}