Listen for cancel shortcuts in alerts, for #110

This commit is contained in:
crschnick 2023-12-08 03:03:19 +00:00
parent b134be7fce
commit 0a8881a9cf
2 changed files with 18 additions and 4 deletions

View file

@ -1,6 +1,5 @@
package io.xpipe.app.core;
import io.xpipe.app.core.mode.OperationMode;
import io.xpipe.app.fxcomps.Comp;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.TrackEvent;
@ -260,11 +259,11 @@ public class AppMainWindow {
contentR.prefWidthProperty().bind(stage.getScene().widthProperty());
contentR.prefHeightProperty().bind(stage.getScene().heightProperty());
if (OsType.getLocal().equals(OsType.LINUX)) {
if (OsType.getLocal().equals(OsType.LINUX) || OsType.getLocal().equals(OsType.MACOS)) {
stage.getScene().addEventFilter(KeyEvent.KEY_PRESSED, event -> {
if (event.getCode().equals(KeyCode.W) && event.isControlDown()) {
if (event.getCode().equals(KeyCode.W) && event.isShortcutDown()) {
AppPrefs.get().closeBehaviour().getValue().run();
event.consume();
OperationMode.close();
}
});
}

View file

@ -4,6 +4,7 @@ import io.xpipe.app.comp.base.LoadingOverlayComp;
import io.xpipe.app.fxcomps.Comp;
import io.xpipe.app.issue.TrackEvent;
import io.xpipe.app.util.ThreadHelper;
import io.xpipe.core.process.OsType;
import javafx.application.Platform;
import javafx.beans.value.ObservableValue;
import javafx.geometry.Insets;
@ -119,6 +120,20 @@ public class AppWindowHelper {
s.setMaxHeight(rectangle2D.getHeight());
});
});
a.getDialogPane().getScene().addEventFilter(KeyEvent.KEY_PRESSED, event -> {
if (OsType.getLocal().equals(OsType.LINUX) || OsType.getLocal().equals(OsType.MACOS)) {
if (event.getCode().equals(KeyCode.W) && event.isShortcutDown()) {
s.close();
event.consume();
return;
}
}
if (event.getCode().equals(KeyCode.ESCAPE)) {
s.close();
event.consume();
}
});
return a;
};