SearchableComboBox Selection change event runs 3 times for each selection.
See original GitHub issueHere I have tried to produce a minimalist example about the problem. Below code is in the Start method where I am showing difference between default and controlfx combox.
@Override
public void start(Stage stage) throws IOException {
//List for the ComboBox.
ObservableList<String> fontFamilies = FXCollections.observableArrayList(Font.getFamilies());
SearchableComboBox<String> searchableComboBox = new SearchableComboBox();
searchableComboBox.setItems(fontFamilies);
searchableComboBox.getSelectionModel().selectedItemProperty().addListener((observableValue, oldValue, newValue) -> {
System.out.println();
System.out.println("ControlFX");
System.out.println("oldValue = " + oldValue);
System.out.println("newValue = " + newValue);
});
//Default javafx ComboBox.
ComboBox<String> javaFXDefault = new ComboBox<>();
javaFXDefault.setItems(fontFamilies);
javaFXDefault.getSelectionModel().selectedItemProperty().addListener((observableValue, oldValue, newValue) -> {
System.out.println();
System.out.println("JavaFX Default");
System.out.println("oldValue = " + oldValue);
System.out.println("newValue = " + newValue);
});
//Scene and containers.
VBox vBox = new VBox(searchableComboBox, javaFXDefault);
Scene scene = new Scene(vBox, 320, 240);
stage.setTitle("Hello!");
stage.setScene(scene);
stage.show();
}
And if i select a single item from the controlFX searchable combobox and default javafx one then below is the log for that :
ControlFX
oldValue = null
newValue = Arial Narrow
ControlFX
oldValue = Arial Narrow
newValue = null
ControlFX
oldValue = null
newValue = Arial Narrow
JavaFX Default
oldValue = null
newValue = Arial Narrow
You can see that we received three log for the SearchableCombox
but one for the JavaFX default one.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6
Top Results From Across the Web
KendoUI ComboBox Change Event Runs Multiple Times
Upon rendering, a page controller sets-up & shims-in its' own Change Event. Oddly, this event gets called TWICE: When I change the Selected...
Read more >OnChange Combobox triggering many times
Thie combobox (DataCardValue28) has two choices, "Open" & "Closed". I want the OnChange fire only if value is changed to "Closed".
Read more >Addin ComboBox OnSelChange fires multiple times wi...
Going off memory, on selection changed event will get fired several times. For instance if a layer get selected and another one de-selected...
Read more >Combo box events are firing two times - Telerik
If you run the example you will notice that with the custom logic in the change event handlers commented a selection in the...
Read more >Events | Select2 - The jQuery replacement for select boxes
Scoped version of change . See below for more details. select2:closing, Triggered before the dropdown is closed. This event can be prevented.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think the problem lies in the observable list. So when we do search in the searchable dropdown list then it’s dynamically change the item list from the dropdown based on keystroke. So if previously selected item is not present in the filtered list then it has to unselect and that’s firing that observable item selection event. Possible way to overwrite is make a shallow clone of the observable list once click on the SearchableComboBox and do those changes in the cloned observable list and then when the dropdown item list close then check whatever is selected in the cloned observable list and then fire ChangeListener on the original observable list with the finally chosen item. don’t know the whole implementation of this ControlFX SearchableCombobox but this approach may work.
Hi @SaingHmineTun i couldn’t find any event which has hidden, showing in it and also that run multiple times like selection change event. Can you check it again plaease.