-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix pressing ESC in text fields (#11190)
* Fix pressing ESC in text fields - Reuse "SearchTextField" - Make ... usage consistent in "Search..." and "Filter groups..." - Let translation key contain the dots * Remove "Close" key binding for Entry Editor. Only "OPEN_CLOSE_ENTRY_EDITOR" (formerly known as "EDIT_ENTRY") is listend to * Add comment * Remove debug logging * Implement unfocus * Fix typo * Support CLEAR_SEARCH shortcut also at GlobalSearchBar * Extract methods * Fix CSS (and simplify GroupTreeView) * Pass "keyBindingRepositor" in constructor
- Loading branch information
Showing
13 changed files
with
145 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,39 @@ | ||
package org.jabref.gui.search; | ||
|
||
import javafx.scene.Node; | ||
import javafx.scene.input.KeyEvent; | ||
|
||
import org.jabref.gui.icon.IconTheme; | ||
import org.jabref.gui.keyboard.KeyBinding; | ||
import org.jabref.gui.keyboard.KeyBindingRepository; | ||
import org.jabref.logic.l10n.Localization; | ||
|
||
import org.controlsfx.control.textfield.CustomTextField; | ||
import org.controlsfx.control.textfield.TextFields; | ||
|
||
public class SearchTextField { | ||
|
||
public static CustomTextField create() { | ||
public static CustomTextField create(KeyBindingRepository keyBindingRepository) { | ||
CustomTextField textField = (CustomTextField) TextFields.createClearableTextField(); | ||
textField.setPromptText(Localization.lang("Search") + "..."); | ||
textField.setLeft(IconTheme.JabRefIcons.SEARCH.getGraphicNode()); | ||
textField.setPromptText(Localization.lang("Search...")); | ||
textField.setId("searchField"); | ||
textField.getStyleClass().add("search-field"); | ||
|
||
Node graphicNode = IconTheme.JabRefIcons.SEARCH.getGraphicNode(); | ||
graphicNode.getStyleClass().add("search-field-icon"); | ||
textField.setLeft(graphicNode); | ||
|
||
textField.addEventFilter(KeyEvent.KEY_PRESSED, event -> { | ||
// Other key bindings are handled at org.jabref.gui.keyboard.TextInputKeyBindings | ||
// We need to handle clear search here to have the code "more clean" | ||
// Otherwise, we would have to add a new class for this and handle the case hitting that class in TextInputKeyBindings | ||
|
||
if (keyBindingRepository.matches(event, KeyBinding.CLEAR_SEARCH)) { | ||
textField.clear(); | ||
event.consume(); | ||
} | ||
}); | ||
|
||
return textField; | ||
} | ||
} |
Oops, something went wrong.