Skip to content

Commit 0742eae

Browse files
author
Martin Plieske
committed
added shortcut (win + down) to minimize main window
1 parent b360676 commit 0742eae

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

src/main/java/de/doubleslash/keeptime/Main.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@
5050
import javafx.scene.control.Alert.AlertType;
5151
import javafx.scene.control.Label;
5252
import javafx.scene.control.TextArea;
53+
import javafx.scene.input.KeyCode;
54+
import javafx.scene.input.KeyCodeCombination;
55+
import javafx.scene.input.KeyCombination;
56+
import javafx.scene.input.KeyEvent;
5357
import javafx.scene.layout.GridPane;
5458
import javafx.scene.layout.Pane;
5559
import javafx.scene.layout.Priority;
@@ -239,6 +243,16 @@ private void initialiseUI(final Stage primaryStage) throws IOException {
239243
// Show the scene containing the root layout.
240244
final Scene mainScene = new Scene(mainPane, Color.TRANSPARENT);
241245

246+
final KeyCombination keyComb = new KeyCodeCombination(KeyCode.DOWN, KeyCombination.META_DOWN);
247+
mainScene.addEventFilter(KeyEvent.KEY_RELEASED, keyEvent -> {
248+
LOG.debug("Key was Pressed '{}'", keyEvent.getCode());
249+
if (keyComb.match(keyEvent)) {
250+
LOG.info("'{}' and '{}' were pressed: iconify window", KeyCode.META, KeyCode.DOWN);
251+
primaryStage.setIconified(true);
252+
keyEvent.consume();
253+
}
254+
});
255+
242256
// Image(Resources.getResource(RESOURCE.ICON_MAIN).toString())); // TODO use an app icon
243257

244258
primaryStage.setTitle("KeepTime");

src/main/java/de/doubleslash/keeptime/view/ViewController.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -443,16 +443,16 @@ private void loadSubStages() {
443443
try {
444444
// Report stage
445445
final FXMLLoader fxmlLoader = createFXMLLoader(RESOURCE.FXML_REPORT);
446-
final Parent sceneRoot = fxmlLoader.load();
447-
sceneRoot.setFocusTraversable(true);
448-
sceneRoot.requestFocus();
446+
final Parent root = fxmlLoader.load();
447+
root.setFocusTraversable(true);
448+
root.requestFocus();
449449
reportController = fxmlLoader.getController();
450450
reportController.setModel(model);
451451
reportController.setController(controller);
452452
reportStage = new Stage();
453453
reportStage.initModality(Modality.APPLICATION_MODAL);
454454

455-
final Scene reportScene = new Scene(sceneRoot);
455+
final Scene reportScene = new Scene(root);
456456
reportScene.setOnKeyPressed(ke -> {
457457
if (ke.getCode() == KeyCode.ESCAPE) {
458458
LOG.info("pressed ESCAPE");

0 commit comments

Comments
 (0)