2 Replies Latest reply on Oct 31, 2012 5:55 AM by sal_iqkhn

    How can I set selection colour on double click only in Flex Tree?

    sal_iqkhn

      Hi

       

      Hope everybody is doing fine.

       

      I want to set selection colour only on double click in flex Tree (mx.controls.Tree). Can anybody help me doing so?

       

      Thanks and best regards.

      Sal

        • 1. Re: How can I set selection colour on double click only in Flex Tree?
          Vibhuti Gosavi(InfoCepts) Level 3

          Hi,

           

          You'll need to extend the Tree class and override the drawItem method to remove the highlight child that is added.

          It's as easy as

           

          protected override function drawItem( item : IListItemRenderer, selected:Boolean = false, highlighted : Boolean = false, caret : Boolean = false, transition : Boolean = false ) : void {

              super.drawItem( item, selected, false, caret, transition );

          }

           

          Then add listeners for clicks and doubleclicks that replicate the functionality of the highlight code you prevented happening in the overridden method.

          Note this doesn't stop the row actually being selected, it just alters the highlight, so it may be a bit confusing for users to have the highlight missing but still have a row selected.

           

          Thanks and Regards,

          ------------------------------------------------------------------------------------------ --

          Vibhuti Gosavi | vgosavi@infocepts.com | www.infocepts.com

          ------------------------------------------------------------------------------------------ --

          1 person found this helpful
          • 2. Re: How can I set selection colour on double click only in Flex Tree?
            sal_iqkhn Level 1

            I am overriding the "drawItem" and "mouseDoubleClickHandler" method but it keeps changing the selected leaf item on opening and closing the tree item. For example if I had selected the 1st leaf item, then closed the folder and reopened, the 2nd item gets selected and if i open and close again, the first item gets selected. Here is the code:

             

             

                                protected override function drawItem( item : IListItemRenderer,  selected:Boolean = false,  highlighted : Boolean = false,  caret : Boolean = false, transition : Boolean = false ) : void

                                {

             

                                            this.slctdItem = item;

                super.drawItem( slctdDItem, true, false, caret, transition );

             

                                }

             

             

                                override protected function mouseDoubleClickHandler(e:MouseEvent):void

                                {

                                          super.mouseDoubleClickHandler(e);

             

                                          this.slctdDItem = this.slctdItem;

                                           this.invalidateList();

                                          this.drawItem(this.slctdDItem, true);

                                }