Error with setOnEditHandler (bug?)

Hi~

I have a tree with a context menu (to rename a node) that when clicked on it makes that node editable.
My issue is with setOnEditHandler, when the state = 1 (editor launched) the text of the node gets lost and becomes “undefined”.

I’ve tried using tree.setItemText which unfortunately causes a postback…

Any ideas?

Here is the relevant part of my code:

menu1.attachEvent("onClick", contextClick);
xtree.setOnEditHandler(checkText);
xtree.enableContextMenu(menu);

         function checkText(state, id, tree, value)
         {
            if(state == 0) //start editing
            {
               nodeText = value;
            }
            if(state == 1) //editor launched
            {
               var mynewText = "<INPUT class=intreeeditRow value=" + nodeText + " type=text>";
               xtree.setItemText(id, mynewText);
            }            
            if(state ==2) //editor about to close
            {
               var regex = new RegExp("^[\\w\\-\\' ]+$");
               if (regex.test(value))
               {
                  return true;
               }
               else
               {
                  return false;
               }
            }
            if(state == 3) //editor closed
            {
               xtree.enableItemEditor(false);
            }
         }       

         function contextClick(id, zoneId, casState)
         {
            if(id=="rename")
            {
               xtree.enableItemEditor(true);
               xtree.editItem(nodeid);
            }
         }



Hi,

we haven’t reproduced the problem locally (attached sample)
02.zip (37.9 KB)

taking your example, I was able to reproduce the problem by commenting out lines 43 and 44. I tried to fix my original error (the undefined value) by adding in those lines, but it caused undesireable results. (Namely, posting back when the Return key is clicked while the editor is launched)…

function checkText(state, id, tree, value){
            	if(state == 0) //start editing
            	{
               		nodeText = value;
            	}
            	if(state == 1) //editor launched
            	{
               //var mynewText = "<INPUT class=intreeeditRow value=" + nodeText + " type=text>";
               //tree.setItemText(id, mynewText);
            	}           
            	if(state ==2) //editor about to close
            	{
               		var regex = new RegExp("^[\\w\\-\\' ]+$");
               		if (regex.test(value))
               		{
                  		return true;
               		}
               		else
               		{
                		 return false;
               		}
            	}
            	if(state == 3) //editor closed
            	{
               		tree.enableItemEditor(false);
            	}
         	}       
		 


onEdit event handler should return true in order to confirm item text:

function checkText(state, id, tree, value){ if(state == 0) //start editing { nodeText = value; } if(state ==2) //editor about to close { var regex = new RegExp("^[\\w\\-\\' ]+$"); if (regex.test(value)) { return true; } else { return false; } } if(state == 3) //editor closed { tree.enableItemEditor(false); } return true }