Skip to content

Commit 0a6c052

Browse files
credmondcalixtus
andauthored
Fixing unwanted tree group node expansion selection bug (#10111)
Co-authored-by: Carl Christian Snethlage <[email protected]>
1 parent ebc1c37 commit 0a6c052

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
8080

8181
### Fixed
8282

83+
- 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)
8384
- 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)
8485
- 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)
8586
- 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)

src/main/java/org/jabref/gui/groups/GroupTreeView.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ private void initialize() {
224224

225225
new ViewModelTreeTableRowFactory<GroupNodeViewModel>()
226226
.withContextMenu(this::createContextMenuForGroup)
227-
.withOnMousePressedEvent((row, event) -> {
227+
.withEventFilter(MouseEvent.MOUSE_PRESSED, (row, event) -> {
228228
if (event.getTarget() instanceof StackPane pane) {
229229
if (pane.getStyleClass().contains("arrow") || pane.getStyleClass().contains("tree-disclosure-node")) {
230230
event.consume();

src/main/java/org/jabref/gui/util/ViewModelTreeTableRowFactory.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
import javafx.beans.value.ObservableValue;
1212
import javafx.css.PseudoClass;
13+
import javafx.event.Event;
14+
import javafx.event.EventType;
1315
import javafx.geometry.Bounds;
1416
import javafx.geometry.Point2D;
1517
import javafx.scene.control.ContextMenu;
@@ -36,6 +38,7 @@ public class ViewModelTreeTableRowFactory<S> implements Callback<TreeTableView<S
3638
private TriConsumer<TreeTableRow<S>, S, ? super DragEvent> toOnDragExited;
3739
private TriConsumer<TreeTableRow<S>, S, ? super DragEvent> toOnDragOver;
3840
private TriConsumer<TreeTableRow<S>, S, ? super MouseDragEvent> toOnMouseDragEntered;
41+
private final Map<EventType<?>, BiConsumer<S, ? super Event>> eventFilters = new HashMap<>();
3942
private final Map<PseudoClass, Callback<TreeTableRow<S>, ObservableValue<Boolean>>> pseudoClasses = new HashMap<>();
4043

4144
public ViewModelTreeTableRowFactory<S> withOnMouseClickedEvent(BiConsumer<S, ? super MouseEvent> event) {
@@ -114,6 +117,11 @@ public ViewModelTreeTableRowFactory<S> withPseudoClass(PseudoClass pseudoClass,
114117
return this;
115118
}
116119

120+
public ViewModelTreeTableRowFactory<S> withEventFilter(EventType<?> event, BiConsumer<S, ? super Event> toCondition) {
121+
this.eventFilters.putIfAbsent(event, toCondition);
122+
return this;
123+
}
124+
117125
public void install(TreeTableView<S> table) {
118126
table.setRowFactory(this);
119127
}
@@ -192,6 +200,10 @@ protected void updateItem(S row, boolean empty) {
192200
setOnMouseDragEntered(event -> toOnMouseDragEntered.accept(this, getItem(), event));
193201
}
194202

203+
for (Map.Entry<EventType<?>, BiConsumer<S, ? super Event>> eventFilter : eventFilters.entrySet()) {
204+
addEventFilter(eventFilter.getKey(), event -> eventFilter.getValue().accept(getItem(), event));
205+
}
206+
195207
for (Map.Entry<PseudoClass, Callback<TreeTableRow<S>, ObservableValue<Boolean>>> pseudoClassWithCondition : pseudoClasses.entrySet()) {
196208
ObservableValue<Boolean> condition = pseudoClassWithCondition.getValue().call(this);
197209
subscriptions.add(BindingsHelper.includePseudoClassWhen(

0 commit comments

Comments
 (0)