I agree this is necessary functionality if you want to hang context
menus on tree nodes, and I have to do exactly the same hack. I've
submitted an enhancement request:
> I have a TreeView, and a ContextMenu triggered by the TreeView. When a
> click occurs in the menu, I want to access the TextNode that is part
> of the TreeView. The problem is that the contextEventTarget available
> in the click handler is an Anchor DOM node that forms part of the
> TextNode's HTML. Is there an easy way to grab the TextNode via a
> ContextMenu event?
> I was able to work around the issue by parsing the ID of the Anchor
> element for the digit at the end. Then I could perform a
> TreeView.getNodeByIndex using the parsed digit to return the node. I
> consider this a hack and am hoping for a better solution.
> Anyone? :)
> FYI. The code I'm using to grab the TextNode from the HTML Node is this:
> var labelEl = this.parent.contextEventTarget;
> var index = labelEl.id.slice('ygtvlabelel'.length);
> var node = tree.getNodeByIndex(index);
> This message has been checked for all known viruses. Virus scanning
> powered by Messagelabs http://www.messagelabs.com For more information
> e-mail : hostmaster@...
This message has been checked for all known viruses. Virus scanning
powered by Messagelabs http://www.messagelabs.com
For more information
e-mail : hostmaster@...