From 4b47dd6db3e333282933cdac3cd51cde1e79d0ab Mon Sep 17 00:00:00 2001 From: LIM0000 Date: Wed, 11 May 2022 16:29:19 +0930 Subject: [PATCH 1/7] Prevent group expansion arrow from activating group when expanding or collapsing --- src/main/java/org/jabref/gui/groups/GroupTreeView.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/jabref/gui/groups/GroupTreeView.java b/src/main/java/org/jabref/gui/groups/GroupTreeView.java index 7e5bc906646..49539f9d7b9 100644 --- a/src/main/java/org/jabref/gui/groups/GroupTreeView.java +++ b/src/main/java/org/jabref/gui/groups/GroupTreeView.java @@ -260,7 +260,7 @@ private void initialize() { .map(this::createContextMenuForGroup) .orElse((ContextMenu) null)); row.addEventFilter(MouseEvent.MOUSE_PRESSED, event -> { - if (event.getButton() == MouseButton.SECONDARY) { + if (event.getButton() == MouseButton.SECONDARY || event.getTarget() instanceof StackPane) { // Prevent right-click to select group event.consume(); } From 012f42bd5e072c18d2468a8824c1f71e0f99894d Mon Sep 17 00:00:00 2001 From: LIM0000 Date: Tue, 17 May 2022 21:02:29 +0930 Subject: [PATCH 2/7] Update solution by picking StackPane that has either arrow or tree-node-disclosure styleclass --- src/main/java/org/jabref/gui/groups/GroupTreeView.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/jabref/gui/groups/GroupTreeView.java b/src/main/java/org/jabref/gui/groups/GroupTreeView.java index 49539f9d7b9..65e5a6fab97 100644 --- a/src/main/java/org/jabref/gui/groups/GroupTreeView.java +++ b/src/main/java/org/jabref/gui/groups/GroupTreeView.java @@ -260,7 +260,11 @@ private void initialize() { .map(this::createContextMenuForGroup) .orElse((ContextMenu) null)); row.addEventFilter(MouseEvent.MOUSE_PRESSED, event -> { - if (event.getButton() == MouseButton.SECONDARY || event.getTarget() instanceof StackPane) { + if (event.getTarget() instanceof StackPane) { + if (((StackPane) event.getTarget()).getStyleClass().toString().equals("arrow") || ((StackPane) event.getTarget()).getStyleClass().toString().equals("tree-disclosure-node")) { + event.consume(); + } + } else if (event.getButton() == MouseButton.SECONDARY) { // Prevent right-click to select group event.consume(); } From 5d3ab6752a77100282953a7936e3816613a7433d Mon Sep 17 00:00:00 2001 From: LIM0000 Date: Tue, 17 May 2022 21:09:04 +0930 Subject: [PATCH 3/7] Check secondary mousebutton, then only check if is StackPane class --- src/main/java/org/jabref/gui/groups/GroupTreeView.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/jabref/gui/groups/GroupTreeView.java b/src/main/java/org/jabref/gui/groups/GroupTreeView.java index 695d471241b..7b718b57fd9 100644 --- a/src/main/java/org/jabref/gui/groups/GroupTreeView.java +++ b/src/main/java/org/jabref/gui/groups/GroupTreeView.java @@ -266,13 +266,13 @@ private void initialize() { .map(this::createContextMenuForGroup) .orElse((ContextMenu) null)); row.addEventFilter(MouseEvent.MOUSE_PRESSED, event -> { - if (event.getTarget() instanceof StackPane) { + if (event.getButton() == MouseButton.SECONDARY) { + // Prevent right-click to select group + event.consume(); + } else if (event.getTarget() instanceof StackPane) { if (((StackPane) event.getTarget()).getStyleClass().toString().equals("arrow") || ((StackPane) event.getTarget()).getStyleClass().toString().equals("tree-disclosure-node")) { event.consume(); } - } else if (event.getButton() == MouseButton.SECONDARY) { - // Prevent right-click to select group - event.consume(); } }); From 04bb61c0a275696becd3cbea86569f8b0d40e602 Mon Sep 17 00:00:00 2001 From: LIM0000 Date: Wed, 18 May 2022 09:09:57 +0930 Subject: [PATCH 4/7] Pattern matching to remove unnecessary StackPane cast --- src/main/java/org/jabref/gui/groups/GroupTreeView.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/jabref/gui/groups/GroupTreeView.java b/src/main/java/org/jabref/gui/groups/GroupTreeView.java index 7b718b57fd9..e24c626d83e 100644 --- a/src/main/java/org/jabref/gui/groups/GroupTreeView.java +++ b/src/main/java/org/jabref/gui/groups/GroupTreeView.java @@ -269,8 +269,8 @@ private void initialize() { if (event.getButton() == MouseButton.SECONDARY) { // Prevent right-click to select group event.consume(); - } else if (event.getTarget() instanceof StackPane) { - if (((StackPane) event.getTarget()).getStyleClass().toString().equals("arrow") || ((StackPane) event.getTarget()).getStyleClass().toString().equals("tree-disclosure-node")) { + } else if (event.getTarget() instanceof StackPane pane) { + if (pane.getStyleClass().toString().equals("arrow") || pane.getStyleClass().toString().equals("tree-disclosure-node")) { event.consume(); } } From 47fbbff294736bb333c8a263affe702f837371ec Mon Sep 17 00:00:00 2001 From: LIM0000 Date: Wed, 18 May 2022 22:22:16 +0930 Subject: [PATCH 5/7] Update equal() to contains() as object could have multiple styles --- src/main/java/org/jabref/gui/groups/GroupTreeView.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/jabref/gui/groups/GroupTreeView.java b/src/main/java/org/jabref/gui/groups/GroupTreeView.java index e24c626d83e..b4d3ea75a61 100644 --- a/src/main/java/org/jabref/gui/groups/GroupTreeView.java +++ b/src/main/java/org/jabref/gui/groups/GroupTreeView.java @@ -270,7 +270,7 @@ private void initialize() { // Prevent right-click to select group event.consume(); } else if (event.getTarget() instanceof StackPane pane) { - if (pane.getStyleClass().toString().equals("arrow") || pane.getStyleClass().toString().equals("tree-disclosure-node")) { + if (pane.getStyleClass().contains("arrow") || pane.getStyleClass().contains("tree-disclosure-node")) { event.consume(); } } From 81f25f87163343837a2eee0e4955f73d0d30a97a Mon Sep 17 00:00:00 2001 From: LIM0000 Date: Sun, 22 May 2022 23:31:08 +0930 Subject: [PATCH 6/7] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8af025df4c1..3838f5897a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve - Writing BibTeX data into a PDF (XMP) does not write the `file` field. - Writing BibTeX data into a PDF (XMP) considers the configured keyword separator (and does not use "," as default any more) - The Medline/Pubmed search now also supports the [default fields and operators for searching](https://docs.jabref.org/collect/import-using-online-bibliographic-database#search-syntax). [forum#3554](https://discourse.jabref.org/t/native-pubmed-search/3354) +- We improved group expansion arrow that prevent it from activating group when expanding or collapsing. [#7982](https://github.com/JabRef/jabref/issues/7982) ### Fixed From de1f675afea5a3ed4545e152ac431d186506e724 Mon Sep 17 00:00:00 2001 From: LIM0000 Date: Mon, 23 May 2022 00:28:16 +0930 Subject: [PATCH 7/7] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c4f7a8c960e..a97703c2daf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,7 +22,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve - Writing BibTeX data into a PDF (XMP) does not write the `file` field. - Writing BibTeX data into a PDF (XMP) considers the configured keyword separator (and does not use "," as default any more) - The Medline/Pubmed search now also supports the [default fields and operators for searching](https://docs.jabref.org/collect/import-using-online-bibliographic-database#search-syntax). [forum#3554](https://discourse.jabref.org/t/native-pubmed-search/3354) -- We improved group expansion arrow that prevent it from activating group when expanding or collapsing. [#7982](https://github.com/JabRef/jabref/issues/7982) +- We improved group expansion arrow that prevent it from activating group when expanding or collapsing. [#7982](https://github.com/JabRef/jabref/issues/7982), [#3176](https://github.com/JabRef/jabref/issues/3176) ### Fixed