1 Reply Latest reply on Nov 5, 2013 12:12 AM by jierui001

    Tree node edit

    genek07
      First, sorry for my English.

      It is necessary to rename a treenode by selecting of a menuitem from the contextual menu like to rename folder in Windows explorer.

      Did so:
      1.) Last used treenode:
      (- Tree in MXML)
      <mx:Tree id="computerTree" width="100%" height="100%" labelField="@label" showRoot="true"
      dataProvider="{treeData}"
      contextMenu="{treeMenu}"
      itemRollOver="SetLastTreeItem(event)"
      editable="false"
      itemEditBeginning="Tree_itemEditBeginning(event)"/>

      (- in ActionScript)
      public function SetLastTreeItem(event:ListEvent):void
      {
      lastTreeItem = event.itemRenderer.data as XML;
      }

      2.) eventListener when ContextMenu item "rename" selected:

      public function ContextMenu_SelectItemRename(event:ContextMenuEvent):void
      {
      var y:int;
      y=computerTree.getItemIndex(lastTreeItem);
      tree.editedItemPosition={columnIndex:0, rowIndex:y};
      tree.createItemEditor(0,y);
      }

      But that didn't work:
      - itemEditor appears in necessary position, but empty.
      - When itemEditor is closed there is an error in List.as.

      (TypeError: Error #1009: Cannot access a property or method of a null object reference.
      at mx.controls::List/endEdit()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\controls\Li st.as:2174]
      at mx.controls::List/editorKeyDownHandler()[E:\dev\3.0.x\frameworks\projects\framework\src\m x\controls\List.as:2444])

      May be someone knows the ways to rename a treenode by selecting of a menuitem from the contextual menu, not by mouseClick?

      In adobe manual I has read:
      "To create an editor at other times, set the editedItemPosition property to generate the itemEditBegin event"
      But this event does not come. Text