Created
November 24, 2020 15:04
-
-
Save Mr00Anderson/22fde0d6ca101dbc5956de5ab710544d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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