From 701e73d545e9879163438a95ba9ceb6a33eddb48 Mon Sep 17 00:00:00 2001 From: Aleksandrs Gusevs Date: Tue, 22 Jan 2019 13:28:24 +0200 Subject: [PATCH] Solution for submitting dialog with Ctrl + Enter (#4496) (#4592) * Issue#4496 Added default action invocation in dialog when pressing ctrl+enter * Issue#4496 Added changelog regarding changes made --- CHANGELOG.md | 1 + .../org/jabref/gui/keyboard/KeyBinding.java | 1 + .../java/org/jabref/gui/util/BaseDialog.java | 17 +++++++++++++++++ src/main/resources/l10n/JabRef_en.properties | 2 ++ 4 files changed, 21 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ce2410787c6..9c29a663c2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,6 +50,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# - We added the ability to have an export preference where previously "File"-->"Export"/"Export selected entries" would not save the user's preference[#4495](https://github.com/JabRef/jabref/issues/4495) - We added the ability to add field names from the Preferences Dialog [#4546](https://github.com/JabRef/jabref/issues/4546) - We added the ability change the column widths directly in the main table. [#4546](https://github.com/JabRef/jabref/issues/4546) +- We added the ability to execute default action in dialog by using with Ctrl + Enter combination [#4496](https://github.com/JabRef/jabref/issues/4496) diff --git a/src/main/java/org/jabref/gui/keyboard/KeyBinding.java b/src/main/java/org/jabref/gui/keyboard/KeyBinding.java index cd6f1c67613..b73fbc6b0c3 100644 --- a/src/main/java/org/jabref/gui/keyboard/KeyBinding.java +++ b/src/main/java/org/jabref/gui/keyboard/KeyBinding.java @@ -25,6 +25,7 @@ public enum KeyBinding { ENTRY_EDITOR_PREVIOUS_PANEL_2("Entry editor, previous panel 2", Localization.lang("Entry editor, previous panel 2"), "ctrl+MINUS", KeyBindingCategory.VIEW), DECREASE_TABLE_FONT_SIZE("Decrease table font size", Localization.lang("Decrease table font size"), "ctrl+MINUS", KeyBindingCategory.VIEW), DELETE_ENTRY("Delete entry", Localization.lang("Delete entry"), "DELETE", KeyBindingCategory.BIBTEX), + DEFAULT_DIALOG_ACTION("Execute default action in dialog", Localization.lang("Execute default action in dialog"), "ctrl+ENTER", KeyBindingCategory.VIEW), DOWNLOAD_FULL_TEXT("Look up full text documents", Localization.lang("Look up full text documents"), "alt+F7", KeyBindingCategory.QUALITY), EDIT_ENTRY("Edit entry", Localization.lang("Edit entry"), "ctrl+E", KeyBindingCategory.BIBTEX), EDIT_STRINGS("Edit strings", Localization.lang("Edit strings"), "ctrl+T", KeyBindingCategory.BIBTEX), diff --git a/src/main/java/org/jabref/gui/util/BaseDialog.java b/src/main/java/org/jabref/gui/util/BaseDialog.java index 59f6e034e3b..a05eb2862ce 100644 --- a/src/main/java/org/jabref/gui/util/BaseDialog.java +++ b/src/main/java/org/jabref/gui/util/BaseDialog.java @@ -1,5 +1,9 @@ package org.jabref.gui.util; +import java.util.Optional; + +import javafx.scene.control.Button; +import javafx.scene.control.ButtonType; import javafx.scene.control.Dialog; import javafx.scene.image.Image; import javafx.stage.Stage; @@ -16,6 +20,8 @@ protected BaseDialog() { KeyBindingRepository keyBindingRepository = Globals.getKeyPrefs(); if (keyBindingRepository.checkKeyCombinationEquality(KeyBinding.CLOSE, event)) { close(); + } else if (keyBindingRepository.checkKeyCombinationEquality(KeyBinding.DEFAULT_DIALOG_ACTION, event)) { + getDefaultButton().ifPresent(Button::fire); } }); @@ -24,6 +30,17 @@ protected BaseDialog() { Globals.getThemeLoader().installCss(getDialogPane().getScene(), Globals.prefs); } + private Optional