From 34ac6d1b872199adff80e75370deb1d2cd64b8c2 Mon Sep 17 00:00:00 2001 From: Clunphumb <54066111+Clunphumb@users.noreply.github.com> Date: Tue, 18 Jul 2023 10:51:49 +0200 Subject: [PATCH] Fix issue with actions on empty space of menu items (#10093) This change fixes #8388 by removing CustomMenuItem from several context menus. This also removes the corresponding tooltips. --- CHANGELOG.md | 1 + .../gui/fieldeditors/contextmenu/DefaultMenu.java | 11 ++--------- .../gui/fieldeditors/contextmenu/EditorMenus.java | 9 ++------- src/main/resources/l10n/JabRef_en.properties | 1 - 4 files changed, 5 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0000e8f789f..f62f79d5404 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -120,6 +120,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve - We fixed an issue where fetching an ISBN could lead to application freezing when the fetcher did not return any results. [#9979](https://github.com/JabRef/jabref/issues/9979) - We fixed an issue where closing a library containing groups and entries caused an exception [#9997](https://github.com/JabRef/jabref/issues/9997) - We fixed a bug where the editor for strings in a bibliography file did not sort the entries by their keys [#10083](https://github.com/JabRef/jabref/pull/10083) +- We fixed an issues where clicking on the empty space of specific context menu entries would not trigger the associated action. [#8388](https://github.com/JabRef/jabref/issues/8388) ### Removed diff --git a/src/main/java/org/jabref/gui/fieldeditors/contextmenu/DefaultMenu.java b/src/main/java/org/jabref/gui/fieldeditors/contextmenu/DefaultMenu.java index b6bc78d6707..c5f95b72fa8 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/contextmenu/DefaultMenu.java +++ b/src/main/java/org/jabref/gui/fieldeditors/contextmenu/DefaultMenu.java @@ -4,13 +4,10 @@ import java.util.Objects; import java.util.function.Supplier; -import javafx.scene.control.CustomMenuItem; -import javafx.scene.control.Label; import javafx.scene.control.Menu; import javafx.scene.control.MenuItem; import javafx.scene.control.SeparatorMenuItem; import javafx.scene.control.TextInputControl; -import javafx.scene.control.Tooltip; import org.jabref.logic.cleanup.Formatter; import org.jabref.logic.formatter.Formatters; @@ -47,9 +44,7 @@ private static Menu getCaseChangeMenu(TextInputControl textInputControl) { Menu submenu = new Menu(Localization.lang("Change case")); for (final Formatter caseChanger : Formatters.getCaseChangers()) { - CustomMenuItem menuItem = new CustomMenuItem(new Label(caseChanger.getName())); - Tooltip toolTip = new Tooltip(caseChanger.getDescription()); - Tooltip.install(menuItem.getContent(), toolTip); + MenuItem menuItem = new MenuItem(caseChanger.getName()); EasyBind.subscribe(textInputControl.textProperty(), value -> menuItem.setDisable(StringUtil.isNullOrEmpty(value))); menuItem.setOnAction(event -> textInputControl.textProperty().set(caseChanger.format(textInputControl.textProperty().get()))); @@ -63,9 +58,7 @@ private static Menu getConversionMenu(TextInputControl textInputControl) { Menu submenu = new Menu(Localization.lang("Convert")); for (Formatter converter : Formatters.getConverters()) { - CustomMenuItem menuItem = new CustomMenuItem(new Label(converter.getName())); - Tooltip toolTip = new Tooltip(converter.getDescription()); - Tooltip.install(menuItem.getContent(), toolTip); + MenuItem menuItem = new MenuItem(converter.getName()); EasyBind.subscribe(textInputControl.textProperty(), value -> menuItem.setDisable(StringUtil.isNullOrEmpty(value))); menuItem.setOnAction(event -> textInputControl.textProperty().set(converter.format(textInputControl.textProperty().get()))); diff --git a/src/main/java/org/jabref/gui/fieldeditors/contextmenu/EditorMenus.java b/src/main/java/org/jabref/gui/fieldeditors/contextmenu/EditorMenus.java index eee48807c99..7a31eec6f45 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/contextmenu/EditorMenus.java +++ b/src/main/java/org/jabref/gui/fieldeditors/contextmenu/EditorMenus.java @@ -4,13 +4,10 @@ import java.util.List; import java.util.function.Supplier; -import javafx.scene.control.CustomMenuItem; -import javafx.scene.control.Label; import javafx.scene.control.MenuItem; import javafx.scene.control.SeparatorMenuItem; import javafx.scene.control.TextArea; import javafx.scene.control.TextInputControl; -import javafx.scene.control.Tooltip; import org.jabref.gui.Globals; import org.jabref.gui.actions.ActionFactory; @@ -39,11 +36,9 @@ public class EditorMenus { */ public static Supplier> getNameMenu(final TextInputControl textInput) { return () -> { - CustomMenuItem normalizeNames = new CustomMenuItem(new Label(Localization.lang("Normalize to BibTeX name format"))); + MenuItem normalizeNames = new MenuItem(Localization.lang("Normalize to BibTeX name format")); EasyBind.subscribe(textInput.textProperty(), value -> normalizeNames.setDisable(StringUtil.isNullOrEmpty(value))); normalizeNames.setOnAction(event -> textInput.setText(new NormalizeNamesFormatter().format(textInput.getText()))); - Tooltip toolTip = new Tooltip(Localization.lang("If possible, normalize this list of names to conform to standard BibTeX name formatting")); - Tooltip.install(normalizeNames.getContent(), toolTip); List menuItems = new ArrayList<>(6); menuItems.add(normalizeNames); menuItems.addAll(new DefaultMenu(textInput).get()); @@ -79,7 +74,7 @@ public static Supplier> getDOIMenu(TextArea textArea) { */ public static Supplier> getCleanupUrlMenu(TextArea textArea) { return () -> { - CustomMenuItem cleanupURL = new CustomMenuItem(new Label(Localization.lang("Cleanup URL link"))); + MenuItem cleanupURL = new MenuItem(Localization.lang("Cleanup URL link")); cleanupURL.setDisable(textArea.textProperty().isEmpty().get()); cleanupURL.setOnAction(event -> textArea.setText(new CleanupUrlFormatter().format(textArea.getText()))); List menuItems = new ArrayList<>(); diff --git a/src/main/resources/l10n/JabRef_en.properties b/src/main/resources/l10n/JabRef_en.properties index 8d4f41569a5..39ac7c28624 100644 --- a/src/main/resources/l10n/JabRef_en.properties +++ b/src/main/resources/l10n/JabRef_en.properties @@ -1118,7 +1118,6 @@ Please\ choose\ which\ one\ to\ connect\ to\:=Please choose which one to connect Choose\ OpenOffice/LibreOffice\ executable=Choose OpenOffice/LibreOffice executable Select\ document=Select document HTML\ list=HTML list -If\ possible,\ normalize\ this\ list\ of\ names\ to\ conform\ to\ standard\ BibTeX\ name\ formatting=If possible, normalize this list of names to conform to standard BibTeX name formatting Could\ not\ open\ %0=Could not open %0 Unknown\ import\ format=Unknown import format Style\ selection=Style selection