Fix combobox selection using arrow keys

Utilize the onHiding event rather than onAction event to prevent the
first option from being added when using arrow keys to navigate the
combobox. This will add the selected option when the combobox is
closing.
This commit is contained in:
Devin Bileck 2018-10-13 21:37:22 -07:00
parent 56965c1904
commit 313971d7d8
No known key found for this signature in database
GPG key ID: C86D829C2399D073

View file

@ -604,7 +604,7 @@ public class PreferencesView extends ActivatableViewAndModel<GridPane, Preferenc
fiatCurrenciesComboBox.setItems(allFiatCurrencies);
fiatCurrenciesListView.setItems(fiatCurrencies);
fiatCurrenciesComboBox.setOnAction(e -> {
fiatCurrenciesComboBox.setOnHiding(e -> {
FiatCurrency selectedItem = fiatCurrenciesComboBox.getSelectionModel().getSelectedItem();
if (selectedItem != null) {
preferences.addFiatCurrency(selectedItem);
@ -619,7 +619,7 @@ public class PreferencesView extends ActivatableViewAndModel<GridPane, Preferenc
});
cryptoCurrenciesComboBox.setItems(allCryptoCurrencies);
cryptoCurrenciesListView.setItems(cryptoCurrencies);
cryptoCurrenciesComboBox.setOnAction(e -> {
cryptoCurrenciesComboBox.setOnHiding(e -> {
CryptoCurrency selectedItem = cryptoCurrenciesComboBox.getSelectionModel().getSelectedItem();
if (selectedItem != null) {
preferences.addCryptoCurrency(selectedItem);