Skip to content

Commit

Permalink
Fixing bug introduced in JabRef#9728 which undid/broke this improveme…
Browse files Browse the repository at this point in the history
…nt: JabRef#8785. Now, once again, the mouse click is handled and consumed at the capture stage if the expansion pane is licked, therefore preventing the node from being selected.
  • Loading branch information
credmond committed Jul 24, 2023
1 parent 1332e29 commit 3582ea7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/gui/groups/GroupTreeView.java
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ private void initialize() {
event.consume();
}
}
})
}, true)
.withCustomInitializer(row -> {
// Remove disclosure node since we display custom version in separate column
// Simply setting to null is not enough since it would be replaced by the default node on every change
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@

public class ViewModelTreeTableRowFactory<S> implements Callback<TreeTableView<S>, TreeTableRow<S>> {
private BiConsumer<S, ? super MouseEvent> onMouseClickedEvent;

// True if listener should be at filter stage, otherwise use default Node method
private boolean onMousePressedEventCapturePhase;

private BiConsumer<S, ? super MouseEvent> onMousePressedEvent;
private Consumer<TreeTableRow<S>> toCustomInitializer;
private Function<S, ContextMenu> contextMenuFactory;
Expand All @@ -44,7 +48,12 @@ public ViewModelTreeTableRowFactory<S> withOnMouseClickedEvent(BiConsumer<S, ? s
}

public ViewModelTreeTableRowFactory<S> withOnMousePressedEvent(BiConsumer<S, ? super MouseEvent> event) {
return withOnMousePressedEvent(event, false);
}

public ViewModelTreeTableRowFactory<S> withOnMousePressedEvent(BiConsumer<S, ? super MouseEvent> event, boolean capturePhase) {
this.onMousePressedEvent = event;
this.onMousePressedEventCapturePhase = capturePhase;
return this;
}

Expand Down Expand Up @@ -165,7 +174,11 @@ protected void updateItem(S row, boolean empty) {
}

if (onMousePressedEvent != null) {
setOnMousePressed(event -> onMousePressedEvent.accept(getItem(), event));
if (onMousePressedEventCapturePhase) {
addEventFilter(MouseEvent.MOUSE_PRESSED, event -> onMousePressedEvent.accept(getItem(), event));
} else {
setOnMousePressed(event -> onMousePressedEvent.accept(getItem(), event));
}
}

if (toCustomInitializer != null) {
Expand Down

0 comments on commit 3582ea7

Please sign in to comment.