Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix binding issue for the regex and case sensitive search buttons #7125

Merged
merged 1 commit into from
Nov 26, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/main/java/org/jabref/gui/search/GlobalSearchBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,16 @@ public GlobalSearchBar(JabRefFrame frame, StateManager stateManager, Preferences
// searchModeButton = new Button();
initSearchModifierButtons();

BooleanBinding focusBinding = searchField.focusedProperty()
.or(regularExpressionButton.focusedProperty()
.or(caseSensitiveButton.focusedProperty()));
Comment on lines -130 to -131

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One nitpick, you need to re-add the focusedProperty() of regularExpressionButton and caseSensitiveButton with the new changes. Otherwise, they will disappear if you click on them while the search field is empty.

Sorry about making your life difficult =/

Except that it looks really good. I like this behaviour 😃

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries!
Thank you for your feedback ^^
I now added the focused properties back in 😃!

BooleanBinding focusedOrActive = searchField.focusedProperty()
.or(regularExpressionButton.focusedProperty())
.or(caseSensitiveButton.focusedProperty())
.or(searchField.textProperty()
.isNotEmpty());

regularExpressionButton.visibleProperty().unbind();
regularExpressionButton.visibleProperty().bind(focusBinding);
regularExpressionButton.visibleProperty().bind(focusedOrActive);
caseSensitiveButton.visibleProperty().unbind();
caseSensitiveButton.visibleProperty().bind(focusBinding);
caseSensitiveButton.visibleProperty().bind(focusedOrActive);

StackPane modifierButtons = new StackPane(new HBox(regularExpressionButton, caseSensitiveButton));
modifierButtons.setAlignment(Pos.CENTER);
Expand Down