Simplify handling of window hiding events

This commit is contained in:
Armin Schrenk 2023-11-30 18:22:07 +01:00 committed by GitHub
parent 89b8bc4148
commit 71bf7e0913
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -132,15 +132,7 @@ public class CreateNewVaultLocationController implements FxController {
@FXML
public void initialize() {
var task = backgroundExecutor.submit(this::loadLocationPresets);
var onHiddenAction = window.getOnHidden();
if(onHiddenAction != null) {
window.setOnHidden(evt -> {
task.cancel(true);
onHiddenAction.handle(evt);
});
} else {
window.setOnHidden(_ -> task.cancel(true));
}
window.addEventHandler(WindowEvent.WINDOW_HIDING, _ -> task.cancel(true));
locationPresetsToggler.selectedToggleProperty().addListener(this::togglePredefinedLocation);
usePresetPath.bind(locationPresetsToggler.selectedToggleProperty().isNotEqualTo(customRadioButton));
}