Java源码示例:com.badlogic.gdx.scenes.scene2d.utils.FocusListener

示例1
@Override
public void process(final LmlParser parser, final LmlTag tag, final Actor actor, final String rawAttributeData) {
    final ActorConsumer<?, Params> action = parser.parseAction(rawAttributeData, tmpParams);
    if (action == null) {
        parser.throwError("Could not find action for: " + rawAttributeData + " with actor: " + actor);
    }
    actor.addListener(new FocusListener() {
        @Override public void keyboardFocusChanged(FocusEvent event, Actor target, boolean focused) {
            if (target == actor) {
                tmpParams.actor = actor;
                tmpParams.focused = focused;
                action.consume(tmpParams);
                tmpParams.reset();
            }
        }
    });
}
 
示例2
@Override
public void process(final LmlParser parser, final LmlTag tag, final Spinner spinner, final String rawAttributeData) {
    boolean value = parser.parseBoolean(rawAttributeData, spinner);
    if (value == false) return;

    spinner.addListener(new FocusListener() {
        @Override
        public void keyboardFocusChanged(FocusEvent event, Actor actor, boolean focused) {
            if (focused) {
                Gdx.app.postRunnable(new Runnable() {
                    @Override
                    public void run() {
                        spinner.getTextField().selectAll();
                    }
                });
            }
        }
    });
}