LWJGUI
LWJGUI copied to clipboard
Scrollpane/VBox containing BorderPane's allow only the last item to be interacted with
For BorderPane the public void calculateNodeBounds() calculation sets the lower Y coordinate in such a way that all BorderPane instances in the VBox have the same starting Y coordinate.
This makes it so that in the class Context the method Node calculateHoverRecursive(Node parent, Node root) only ever allows interaction with the last item, because it thinks its bounds cover all the rest.
When switching the VBox items to a different class such as HBox the problem does not occur. Seem's like unintentional behavior of the BorderPane class.
Reproducible demo:
import lwjgui.scene.Scene;
import lwjgui.scene.Window;
import lwjgui.scene.control.Button;
import lwjgui.scene.control.ScrollPane;
import lwjgui.scene.layout.BorderPane;
import lwjgui.scene.layout.StackPane;
import lwjgui.scene.layout.VBox;
public class Bug extends LWJGUIApplication {
public static final int WIDTH = 300;
public static final int HEIGHT = 300;
public static void main(String[] args) {
launch(args);
}
@Override
public void start(String[] args, Window window) {
StackPane root = new StackPane();
VBox box = new VBox();
ScrollPane scrollPane = new ScrollPane();
scrollPane.setPrefHeight(HEIGHT);
scrollPane.setContent(box);
root.getChildren().add(scrollPane);
for (int i = 0; i < 6; i++) {
BorderPane wrapper = new BorderPane();
wrapper.setLeft(new Button("Click"));
wrapper.setPrefHeight(25);
wrapper.setFillToParentWidth(true);
box.getChildren().add(wrapper);
}
window.setScene(new Scene(root, WIDTH, HEIGHT));
window.show();
}
@Override
protected void run() {}
}
The "fix" I'm using for now is:
HBox wrapper = new HBox(); // just don't use BorderPane in scroll-panes
wrapper.getChildren().add(new Button("Click"));
Hi, thanks for the ticket. Currently, I am not having much free time, and the time I do have I seem to be spending it more on my JadeFX project (successor to LWJGUI). JadeFX currently does have BorderPane implementation, but it is missing many standard control objects.
I can get a fix out for this, but might need some time.
No rush. If JadeFX is the successor I'll happily switch to it once its more complete. For now I have some workarounds.