Skip to content

Commit

Permalink
Add pressing enter when the search field is focused as a way to trigg…
Browse files Browse the repository at this point in the history
…er search (#7377)
  • Loading branch information
DominikVoigt committed Jan 22, 2021
1 parent 94f4c1e commit fac0a23
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
import javafx.scene.control.TextField;
import javafx.scene.input.KeyCode;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
import javafx.scene.layout.StackPane;
Expand Down Expand Up @@ -83,6 +84,13 @@ protected Node createContentPane() {

viewModel.queryProperty().bind(query.textProperty());

// Allows to trigger search on pressing enter
query.setOnKeyPressed(event -> {
if (event.getCode() == KeyCode.ENTER) {
viewModel.search();
}
});

// Create button that triggers search
Button search = new Button(Localization.lang("Search"));
search.setDefaultButton(false);
Expand Down

0 comments on commit fac0a23

Please sign in to comment.