io.github.factoryfx.javafx.util.CheckComboBoxHelper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of javafxFactoryEditing Show documentation
Show all versions of javafxFactoryEditing Show documentation
factoryfx dependency injection framework
package io.github.factoryfx.javafx.util;
import java.util.function.Consumer;
import javafx.beans.value.ChangeListener;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Skin;
import javafx.scene.control.SkinBase;
import org.controlsfx.control.CheckComboBox;
public class CheckComboBoxHelper {
//workaround: http://stackoverflow.com/questions/25177523/how-to-listen-to-open-close-events-of-a-checkcombobox
public static void addOpenCloseListener(CheckComboBox comboBox, Consumer> listener){
comboBox.skinProperty().addListener((ChangeListener) (skinObs, oldVal, newVal) -> {
if (oldVal == null && newVal != null) {
SkinBase skin = (SkinBase) newVal;
ComboBox combo = (ComboBox) skin.getChildren().get(0);
combo.showingProperty().addListener((obs, hidden, showing) -> listener.accept(comboBox));
}
});
}
}