Skip to content

Commit

Permalink
Support multiple AutocompleteInputs on the same scene
Browse files Browse the repository at this point in the history
  • Loading branch information
Bios-Marcel committed Jul 21, 2024
1 parent 46ed36c commit 635a08f
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/main/java/link/biosmarcel/baka/view/AutocompleteInput.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ private void updatePopupItems(final Collection<String> newItems) {
}

private void hidePopup() {
toBack();
completionList.setVisible(false);
}

Expand Down Expand Up @@ -201,7 +202,7 @@ private void refreshPopup() {

// Since we are using a hacky way of rendering the popup, we need to make sure it doesn't render
// behind other components, as it is part of the Pane, but outside the pane bounds.
toFront(completionList);
toFront();

completionList.setVisible(true);
}
Expand All @@ -228,10 +229,18 @@ public void indicateError() {
input.getStyleClass().add("text-field-error");
}

private void toFront(Node node) {
node.setViewOrder(-1);
private void toFront() {
recursivelySetViewOrder(completionList, -1);
}

private void toBack() {
recursivelySetViewOrder(completionList, 0);
}

private void recursivelySetViewOrder(final Node node, final double viewOrder) {
node.setViewOrder(viewOrder);
if (node.getParent() != null) {
toFront(node.getParent());
recursivelySetViewOrder(node.getParent(), viewOrder);
}
}

Expand Down

0 comments on commit 635a08f

Please sign in to comment.