Ensure Material Combobox closes when using buttons

This commit is contained in:
SiboVG 2024-08-11 16:25:59 +02:00
parent 4dbbc0f4fd
commit bc60e30c72
2 changed files with 12 additions and 2 deletions

View File

@ -334,7 +334,7 @@ public class GroupableAndSearchableComboBox<G extends Group, T extends Groupable
});
}
private void hidePopups() {
public void hidePopups() {
hideGroupsPopup();
hideSearchPopup();
}

View File

@ -44,7 +44,7 @@ public abstract class MaterialComboBox extends JComboBox<Material> {
});
});
return new GroupableAndSearchableComboBox<>(mm,
GroupableAndSearchableComboBox<MaterialGroup, Material> comboBox = new GroupableAndSearchableComboBox<>(mm,
trans.get("MaterialPanel.MaterialComboBox.placeholder"), customMaterialButton, editMaterialsButton) {
@Override
public String getDisplayString(Material item) {
@ -55,5 +55,15 @@ public abstract class MaterialComboBox extends JComboBox<Material> {
return baseText;
}
};
// Ensure combobox is hidden when buttons are clicked
customMaterialButton.addActionListener(e -> {
comboBox.hidePopups();
});
editMaterialsButton.addActionListener(e -> {
comboBox.hidePopups();
});
return comboBox;
}
}