PDA

View Full Version : TreeNodeUI beforeclick event cancelation not working



jmakeig
11 Jan 2007, 9:10 AM
I was trying to intercept the click event on a TreeNode using the beforeclick event in TreeNodeUI. I need to check some conditions and cancel the node click in certain cases (such as if the user will be abandoning unsaved work). However, as it is currently implemented, TreeNodeUI's fireEvent method swallows the event handler's return

fireEvent : function(){
this.node.fireEvent.apply(this.node, arguments);
}
When I changed the above to

fireEvent : function(){
return this.node.fireEvent.apply(this.node, arguments);
}
everything seems hunky dunky.
On a related note, why doesn't TreeNodeUI extend Observable? If it did, it would get this functionality for free.
Keep up the amazing work.

Justin

jack.slocum
12 Jan 2007, 5:48 AM
Thanks, that indeed is a bug.

You could extend TreeNodeUI to add Observable type functionality if you wanted to. It doesn't currently to keep the API clean. You can listen on a node, or on the tree. Adding in a 3rd listening spot seems like extra complexity IMO but I could be wrong.