Skip to content

Instantly share code, notes, and snippets.

@Mr00Anderson
Created November 24, 2020 15:04
Show Gist options
  • Save Mr00Anderson/22fde0d6ca101dbc5956de5ab710544d to your computer and use it in GitHub Desktop.
Save Mr00Anderson/22fde0d6ca101dbc5956de5ab710544d to your computer and use it in GitHub Desktop.
package app.virtualhex.gdx.engine.scene2d;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.TextField;
import com.badlogic.gdx.utils.Array;
/**
* this class will notify a listener when a text field is unfocused
*/
public class TextFieldChangedNotify extends TextField implements Focusable{
public Array<TextFieldChangeListener> changeListenerList = new Array<>();
public TextFieldChangedNotify(String text, Skin skin) {
super(text, skin);
init();
}
public TextFieldChangedNotify(String text, Skin skin, String styleName) {
super(text, skin, styleName);
init();
}
public TextFieldChangedNotify(String text, TextFieldStyle style) {
super(text, style);
init();
}
// Lost notify a listener
public void init(){
addListener(new OnFocusLossFocusListener(this, changeListenerList));
addListener(new EnterTabListener(this, changeListenerList));
}
public void addChangeListener(TextFieldChangeListener changeListener){
changeListenerList.add(changeListener);
}
@Override
public void focusLost() {
}
@Override
public void focusGained() {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment