mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-21 23:20:23 +00:00
Listen for cancel shortcuts in alerts, for #110
This commit is contained in:
parent
b134be7fce
commit
0a8881a9cf
2 changed files with 18 additions and 4 deletions
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue