mirror of
https://github.com/xpipe-io/xpipe.git
synced 2026-09-28 19:35:41 +00:00
Listen for cancel shortcuts in alerts, for #110
This commit is contained in:
@@ -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();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user