@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); } }); }
@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; }
@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()); } }