Hi,
I've added a context-menu to my TreeView. Now, if I just
hover(position) the mouse over a tree-node and right click on that
node(without selecting that node with a left-click) then
TreeView.getSelectedNode() returns null. But I can certainly get the
node by using Tree.get(). So just wanted to check if this is as
designed. Anyways, just wanted to share my test-case so that other
beginners like myself can save some time.
here's my existing code(Note: In this particular code-path I'm going
to stop using getSelectedNode and just use Tree.get):
my_tree.setMenuHandler(new MenuHandler.Adapter() {
public boolean configureContextMenu( Component component, Menu menu,
int x, int y ) {
Path nodePath = my_tree.getNodeAt(y);
Object obj = my_tree.getSelectedNode();
if (obj == null) {
obj = Tree.get(my_tree.getTreeData(), nodePath);
if (obj == null)
return true;
}
// use obj ...
return false;
}
thanks