diff --git a/CHANGELOG.md b/CHANGELOG.md index f62f79d5404..3a242501005 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -79,6 +79,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve ### Fixed +- We fixed an issue where clicking the group expansion pane/arrow caused the node to be selected, when it should just expand/detract the node - [#10111](https://github.com/JabRef/jabref/pull/10111) - We fixed an issue where the browser import would add ' characters before the BibTeX entry on Linux. [#9588](https://github.com/JabRef/jabref/issues/9588) - We fixed an issue where searching for a specific term with the DOAB fetcher lead to an exception. [#9571](https://github.com/JabRef/jabref/issues/9571) - We fixed an issue where the "Import" -> "Library to import to" did not show the correct library name if two opened libraries had the same suffix. [#9567](https://github.com/JabRef/jabref/issues/9567) diff --git a/src/main/java/org/jabref/gui/groups/GroupTreeView.java b/src/main/java/org/jabref/gui/groups/GroupTreeView.java index 81c7327aa72..e34fefb9de4 100644 --- a/src/main/java/org/jabref/gui/groups/GroupTreeView.java +++ b/src/main/java/org/jabref/gui/groups/GroupTreeView.java @@ -224,7 +224,7 @@ private void initialize() { new ViewModelTreeTableRowFactory() .withContextMenu(this::createContextMenuForGroup) - .withOnMousePressedEvent((row, event) -> { + .withEventFilter(MouseEvent.MOUSE_PRESSED, (row, event) -> { if (event.getTarget() instanceof StackPane pane) { if (pane.getStyleClass().contains("arrow") || pane.getStyleClass().contains("tree-disclosure-node")) { event.consume(); diff --git a/src/main/java/org/jabref/gui/util/ViewModelTreeTableRowFactory.java b/src/main/java/org/jabref/gui/util/ViewModelTreeTableRowFactory.java index cae8d1c353c..acb4ee65fd0 100644 --- a/src/main/java/org/jabref/gui/util/ViewModelTreeTableRowFactory.java +++ b/src/main/java/org/jabref/gui/util/ViewModelTreeTableRowFactory.java @@ -10,6 +10,8 @@ import javafx.beans.value.ObservableValue; import javafx.css.PseudoClass; +import javafx.event.Event; +import javafx.event.EventType; import javafx.geometry.Bounds; import javafx.geometry.Point2D; import javafx.scene.control.ContextMenu; @@ -36,6 +38,7 @@ public class ViewModelTreeTableRowFactory implements Callback, S, ? super DragEvent> toOnDragExited; private TriConsumer, S, ? super DragEvent> toOnDragOver; private TriConsumer, S, ? super MouseDragEvent> toOnMouseDragEntered; + private final Map, BiConsumer> eventFilters = new HashMap<>(); private final Map, ObservableValue>> pseudoClasses = new HashMap<>(); public ViewModelTreeTableRowFactory withOnMouseClickedEvent(BiConsumer event) { @@ -114,6 +117,11 @@ public ViewModelTreeTableRowFactory withPseudoClass(PseudoClass pseudoClass, return this; } + public ViewModelTreeTableRowFactory withEventFilter(EventType event, BiConsumer toCondition) { + this.eventFilters.putIfAbsent(event, toCondition); + return this; + } + public void install(TreeTableView table) { table.setRowFactory(this); } @@ -192,6 +200,10 @@ protected void updateItem(S row, boolean empty) { setOnMouseDragEntered(event -> toOnMouseDragEntered.accept(this, getItem(), event)); } + for (Map.Entry, BiConsumer> eventFilter : eventFilters.entrySet()) { + addEventFilter(eventFilter.getKey(), event -> eventFilter.getValue().accept(getItem(), event)); + } + for (Map.Entry, ObservableValue>> pseudoClassWithCondition : pseudoClasses.entrySet()) { ObservableValue condition = pseudoClassWithCondition.getValue().call(this); subscriptions.add(BindingsHelper.includePseudoClassWhen(