|
Re: Tree node deselection [message #453955 is a reply to message #453954] |
Thu, 14 April 2005 20:08 |
Emil Crumhorn Messages: 169 Registered: July 2009 |
Senior Member |
|
|
Just listen to the mouse event, get the treenode for the location where the
mouse was pressed, and if that's null, you know that they clicked somewhere
there is no node.. at that point you can deselect all nodes in the tree (and
show your menu).
Something along the lines of
tree.addMouseListener(new MouseAdapter() {
public void mouseDown(MouseEvent e) {
TreeItem ti = tree.getItem(new Point(e.x, e.y));
if (ti == null) {
tree.deselectAll();
// etc....
}
}
});
or just SWT.MouseDown, or any other listener you prefer.
Emil
"Robin" <rraddatz@us.ibm.com> wrote in message
news:5f789b3ac3a3ffed7faf5630d408ac80$1@www.eclipse.org...
>I have a tree that should allow only a single selection. If the user has
>selected a node and then right-clicks, I pop up a certain menu. However,
>if the user has selected no nodes, I want to pop up a different generic
>menu. I can't seem to figure out how to allow the user to deselect all
>nodes in the tree. Once a node is selected, there is always a node
>selected, so they will never see that generic menu. Is there a way to do
>this? I see you can do it if you set the style to SWT.MULTI, but I don't
>want to allow the user to select more than one node.
>
> Thanks,
> Robin
>
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03191 seconds