From 7d9514abae294079649a1cf72db3f2054ac9dd27 Mon Sep 17 00:00:00 2001 From: Jeddunk Date: Sun, 30 Aug 2020 16:15:46 +0200 Subject: [PATCH] You can now press enter in the "Game..." text field to start a search. --- src/main/java/Controller.java | 20 +++++++++++-------- .../java/SearchResultWindowController.java | 8 ++++++-- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/main/java/Controller.java b/src/main/java/Controller.java index 79b4516..223092e 100644 --- a/src/main/java/Controller.java +++ b/src/main/java/Controller.java @@ -21,6 +21,7 @@ import javafx.concurrent.Service; import javafx.concurrent.Task; import javafx.event.Event; import javafx.fxml.FXML; +import javafx.fxml.Initializable; import javafx.scene.input.KeyCode; import javafx.scene.input.KeyEvent; import javafx.scene.paint.Color; @@ -40,17 +41,15 @@ import util.SteamAppsListCache; import java.io.File; import java.io.IOException; import java.io.InputStream; +import java.net.URL; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.StandardCopyOption; -import java.util.List; -import java.util.Map; -import java.util.NoSuchElementException; -import java.util.Objects; +import java.util.*; import java.util.stream.Stream; -public class Controller { +public class Controller implements Initializable { private static final String REGEX = "(?steam_api(?:64)?.dll)$"; public Label creamApiDllApplied; @@ -111,8 +110,15 @@ public class Controller { } @FXML - public void initialize() { + @Override + public void initialize(URL location, ResourceBundle resources) { appId_textfield.textProperty().addListener(appIdChangesGameName()); + game_name_textfield.setOnKeyReleased(event -> { + KeyCode code = event.getCode(); + if (code.equals(KeyCode.ENTER)) { + getAppId(); + } + }); language_combobox.setItems(FXCollections.observableArrayList(config.getLanguages())); language_combobox.setTooltip(new Tooltip()); language_combobox.setEditable(false); @@ -286,7 +292,6 @@ public class Controller { } public void getAppId() { - //final App game = cache.findGame(game_name_textfield.getText()); final List games = cache.findListOfGames(game_name_textfield.getText()); if (games.isEmpty()) { appId_textfield.setText("-1"); @@ -306,7 +311,6 @@ public class Controller { Stage stage = new Stage(); stage.initModality(Modality.APPLICATION_MODAL); stage.setResizable(false); - //stage.initStyle(StageStyle.UNDECORATED); stage.setTitle("Choose game..."); stage.setScene(new Scene(root1)); stage.show(); diff --git a/src/main/java/SearchResultWindowController.java b/src/main/java/SearchResultWindowController.java index ded05bd..771acd5 100644 --- a/src/main/java/SearchResultWindowController.java +++ b/src/main/java/SearchResultWindowController.java @@ -14,6 +14,7 @@ */ import javafx.fxml.FXML; +import javafx.fxml.Initializable; import javafx.scene.control.*; import javafx.scene.control.cell.TreeItemPropertyValueFactory; import javafx.scene.input.MouseButton; @@ -21,9 +22,11 @@ import javafx.scene.input.MouseEvent; import javafx.stage.Stage; import pojo.App; +import java.net.URL; import java.util.List; +import java.util.ResourceBundle; -public class SearchResultWindowController { +public class SearchResultWindowController implements Initializable { @FXML public Button okButton; @@ -45,7 +48,8 @@ public class SearchResultWindowController { } @FXML - public void initialize() { + @Override + public void initialize(URL location, ResourceBundle resources) { } public void initMe(List games) {