As you can see that the control that is visible (and above the other) gets the mouse events. I think this behavior is correct and expected. I don't suppose you are asking that even though node1
is above node2
and drawn above but still lets node2
receive all the mouse events. Which might not be possible using standard ways.
If however you are asking about ensuring that node2
appears above node1
and thus receives mouse events, you can reverse the creation order, or you can use Control#moveAbove(Control)
like below:
Node node1 = new Node(this, SWT.NONE, "node 1");
node1.setBounds(25, 25, 50, 50);
Node node2 = new Node(this, SWT.NONE, "node 2");
node2.setBounds(35, 35, 60, 60);
node2.setBackground(new Color(Display.getCurrent(), 75, 75, 75));
// Use moveAbove(null) to move node2 above all its siblings
node2.moveAbove(node1);