2 Replies Latest reply on Jan 8, 2010 10:05 AM by sebastiantoro84

    Edit the selectedItem with double click instead of one in a Tree

    sebastiantoro84

      What I whant to do is that when you doubleclick on top of the selected item it gets in the "editable mode" where you can change the label. By default, if you do a single click on an item it gets into "editable mode", I want to do it with a Doubleclick, someone knows how to do this?

       

      Thanks for the help

       

      Sebastián Toro O.

        • 1. Re: Edit the selectedItem with double click instead of one in a Tree
          Flex harUI Adobe Employee

          I wired up DataGrid to do this on my blog.  You can probably copy the way I did it for Tree.

           

          Alex Harui

          Flex SDK Developer

          Adobe Systems Inc.

          Blog: http://blogs.adobe.com/aharui

          • 2. Re: Edit the selectedItem with double click instead of one in a Tree
            sebastiantoro84 Level 1

            Dear Alex

                          Thank you very much for your prompt reply, sadly your blog didn't help me, thanks though. I came with an idea that solved my problem, here it goes:

             

            First be sure to have the editable property ser to false, second set the doubleClickEnabled property to true, and then add the listener itemDoubleClick to the function you want, for instance "editItem(event)". And last use a creationComplete function to add an event listener for the ListEvent.ITEM_EDIT_END event:

             

            public function init():void{

                           addEventListener(ListEvent.ITEM_EDIT_END,finEditItem);

            }

             

            this is the editItem function:

             

            private function  editItem(event:ListEvent):void{
                            var listEvent:ListEvent = new ListEvent(ListEvent.ITEM_EDIT_BEGINNING, false, true);
                            editable = true;
                            listEvent.rowIndex = event.rowIndex;
                            listEvent.columnIndex = 0;
                            listEvent.itemRenderer = event.itemRenderer;
                            dispatchEvent(listEvent);               
            }

             

            when you finish editing the item then it will dispatch the ListEvent.ITEM_EDIT_END event and call the next function:

             

            private function  finEditItem(event:ListEvent):void{
                            editable = false;
            }

             

            Hope it helps.

             

            Sebastián Toro O

            _______________

            Elohim Melej