Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pressing ESC while searching clears searchfield and selects first available entry #3760

Merged
merged 3 commits into from
Mar 16, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions src/main/java/org/jabref/gui/search/GlobalSearchBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import javafx.scene.control.ToolBar;
import javafx.scene.control.Tooltip;
import javafx.scene.control.cell.TextFieldListCell;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.input.MouseButton;
import javafx.scene.layout.BorderPane;
Expand Down Expand Up @@ -136,11 +137,17 @@ public void actionPerformed(ActionEvent e) {
KeyBindingRepository keyBindingRepository = Globals.getKeyPrefs();
addEventFilter(KeyEvent.KEY_PRESSED, event -> {
Optional<KeyBinding> keyBinding = keyBindingRepository.mapToKeyBinding(event);
if (keyBinding.isPresent() && keyBinding.get().equals(KeyBinding.GLOBAL_SEARCH)) {
globalSearch.setSelected(true);
searchPreferences.setGlobalSearch(globalSearch.isSelected());
updateOpenCurrentResultsTooltip(globalSearch.isSelected());
focus();
if (keyBinding.isPresent()) {
if (keyBinding.get().equals(KeyBinding.GLOBAL_SEARCH)) {
globalSearch.setSelected(true);
searchPreferences.setGlobalSearch(globalSearch.isSelected());
updateOpenCurrentResultsTooltip(globalSearch.isSelected());
focus();
} else if (keyBinding.get().equals(KeyBinding.CLEAR_SEARCH)) {
// Clear search and select first entry, if available
clearSearch();
frame.getCurrentBasePanel().getMainTable().getSelectionModel().selectFirst();
}
}
});

Expand Down Expand Up @@ -204,6 +211,7 @@ public void actionPerformed(ActionEvent e) {
searchField,
currentResults
);

this.setAlignment(Pos.CENTER_LEFT);
}

Expand Down