Replies: 7 comments
-
Is the question or bug about "in our application we don't see the event, but in others the event is there" ? |
Beta Was this translation helpful? Give feedback.
-
In our applications the SWT.Expand event is NOT sent, but in a tiny Tree test snippet it is sent. Where should I set breakpoints that are triggered before the expansion happens after having pressed the cursor-right key? The question is "how to debug this problem in our application", so I can find out what triggers it, so I get empowered to create a reproducer test snippet. |
Beta Was this translation helpful? Give feedback.
-
I would debug it in a (working) tiny SWT test snippet and put breakpoints in all code backwards from the place where event is received. |
Beta Was this translation helpful? Give feedback.
-
That's what I've already tried with this snippet: import org.eclipse.swt.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;
public class Snippet202 {
public static void main(String[] args) {
Display display = new Display();
final Shell shell = new Shell(display);
shell.setText("Snippet 202");
shell.setLayout (new FillLayout());
final Tree tree = new Tree(shell, SWT.VIRTUAL | SWT.BORDER);
tree.addListener(SWT.SetData, event -> {
TreeItem item = (TreeItem)event.item;
TreeItem parentItem = item.getParentItem();
String text = null;
if (parentItem == null) {
text = "node "+tree.indexOf(item);
} else {
text = parentItem.getText()+" - "+parentItem.indexOf(item);
}
item.setText(text);
item.setItemCount(10);
});
tree.setItemCount(20);
tree.addListener(SWT.Expand, event -> System.out.println("expanded"));
shell.setSize(400, 300);
shell.open();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}
} but it does not help. Having set a break-point in the listener gives following call stack:
and I already wrote in #1334, that |
Beta Was this translation helpful? Give feedback.
-
Just a wild guess: I assume in your application the tree is nested in many other components/scrollbars/panes etc. Try to create similar widget hierarchy in the simple snippet, may be some of the parent SWT widgets "eats" the event before it is arrived at the tree. |
Beta Was this translation helpful? Give feedback.
-
Shame on me - it was an interfering key listener. I've commented all non-essential code in our Tree-wrapping class; then it worked. Thanks for the tips. |
Beta Was this translation helpful? Give feedback.
-
Sometimes one just need to discuss the problem with someone else, even if the someone else has no clue :-) |
Beta Was this translation helpful? Give feedback.
-
How can I debug SWT in our applications to find out why no SWT.Expand event is sent when pressing the right arrow key on a tree node?
#1334
Beta Was this translation helpful? Give feedback.
All reactions