Reputation: 978
I have problem where I have BorderPane
in which center's there is TabPane
with Tabs
that have various other Nodes
(say another BorderPane
for example).
When I try to for example use:
parentBorderPane.setOnMouseDragged(e -> System.out.println("DRAGGING"));
parentBorderPane.setOnMouseMoved(e -> System.out.println("MOVING"));
...events never occur (I can catch them on currently opened Tab's
content, but that's not what I want).
I require to know when such events occur in BOTH places, (1st event goes through content of Tab
, then through containing TabPane
, then through main parent BorderPane
). So I can't use (on any of children):
this.setMouseTransparent(true);
How can this be solved?
EDIT
Let me add that main problem is with TabPane
- its the one that doesn't pass events to next node in stack.
EDIT 2
public class T extends Application
{
public static void main(String[] args) throws Exception
{
launch(args);
}
@Override
public void start(Stage stage) throws Exception
{
stage.setTitle("Test");
Scene scene = new Scene(this.working()); // change to this.problem();
stage.setScene(scene);
stage.show();
}
private BorderPane working()
{
BorderPane main = new BorderPane();
main.setPrefSize(800, 600);
main.setOnMouseMoved(e -> System.out.println("MOVING ON MAIN"));
BorderPane sub = new BorderPane();
sub.setOnMouseMoved(e -> System.out.println("MOVING ON SUB"));
main.setCenter(sub);
return main;
}
private BorderPane problem()
{
BorderPane main = new BorderPane();
main.setPrefSize(800, 600);
main.setOnMouseMoved(e -> System.out.println("MOVING ON MAIN"));
BorderPane sub = new BorderPane();
sub.setOnMouseMoved(e -> System.out.println("MOVING ON SUB"));
main.setCenter(sub);
TabPane tabs = new TabPane();
tabs.setOnMouseMoved(e -> System.out.println("MOVING ON TABS"));
sub.setCenter(tabs);
return main;
}
}
working()
- Normal Panes
stacked on each other will work as they should (pass events from top to bottom of stack).
problem()
- Because TabPane
is sub-class of Control (which I am currently investagating), it stops mouse events and doesn't let parents see them.
Upvotes: 0
Views: 46
Reputation: 978
I found solution - instead of trying to receive event durnig bubble-up phase (child->parent behind) where Control
(parent class of TabPane
) consumes it, I can use event filters and catch event before its consumed.
Upvotes: 2