3 Replies Latest reply on Jun 27, 2007 10:57 AM by NMTAlien

    DoubleClick List Item with Icon (is this a bug)

    GaryThompson76
      DoubleClick event is not called when you double click an Icon displayed in a list !

      Help ! is this a bug or me being thick ??

      Demo App Below (just supply your own Icon.)


      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" width="566" height="526">
      <mx:Script>
      <![CDATA[

      [Embed(source="icons/folder.gif")] public var folderIcon:Class;

      [Bindable]
      public var myList: Array = [ {label:"None", data:"", myIcon:"folderIcon"},
      {label:"Dataset", data:"Dataset", myIcon:"folderIcon"},
      {label:"Image", data:"Image", myIcon:"folderIcon"},
      {label:"Interactive Resource", data:"Interactive", myIcon:"folderIcon"},
      {label:"Moving Image", data:"MovingImage", myIcon:"folderIcon"},
      {label:"Software", data:"Software", myIcon:"folderIcon"},
      {label:"Sound", data:"Sound", myIcon:"folderIcon"},
      {label:"Text", data:"Text", myIcon:"folderIcon"}];

      public function ItemSelected():void {
      Log.text = "Clicked " + listbox.selectedItem.label + "\r" + Log.text;
      }

      public function ItemDoubleClick():void {
      Log.text = "DoubleClicked " + listbox.selectedItem.label + "\r" + Log.text;
      }

      ]]>
      </mx:Script>
      <mx:List x="127" y="30" id="listbox" labelField="label" width="312" height="275"
      borderStyle="solid" iconField="myIcon" cornerRadius="6" enabled="true"
      doubleClickEnabled="true" doubleClick="ItemDoubleClick();" click="ItemSelected();"
      dataProvider="{myList}">
      </mx:List>
      <mx:TextArea x="127" y="393" width="312" height="80" liveScrolling="true" id="Log"/>
      <mx:Label x="128" y="367" text="Log"/>
      </mx:Application>

        • 1. DoubleClick List Item with Icon (is this a bug)
          NMTAlien
          Regarding double clicking the icons in a list box, in our case we have file and folder icons, we were able to fire and catch the click event but the double click event is not working for us either. I too need to know if any one has run into this problem and has a fix because this is hindering our user experience. Anyone have an answer?

          Best,

          J
          • 2. Re: DoubleClick List Item with Icon (is this a bug)
            bsr328
            When the user double clicks, the first click of the double click gets caught as a single click, and the click event is fired. I got around this by creating a custom item renderer to create a click event on the icon itself, then adding a double click event to the label of the item. Not ideal, but hope it helps!
            • 3. DoubleClick List Item with Icon (is this a bug)
              NMTAlien Level 1
              You got my mind cranking so your fix did help me. Thank you very much. Here is my archaic workaround.

              // To get around the double click on the list box adobe bug
              private var doubleClickTimer:Timer = new Timer(1000, 1); // one second
              private var singleClick:Boolean = false;

              private function courseFiles_click():void
              {
              if(isDoubleClick())
              courseFiles_doubleClick();
              }
              private function isDoubleClick():Boolean
              {
              var myReturn:Boolean = false; // default false
              if(singleClick)
              myReturn = true; // we get here if it is a double click so return true
              if(singleClick == false)
              {
              // init timer
              doubleClickTimer.start();
              doubleClickTimer.addEventListener(TimerEvent.TIMER_COMPLETE, onTimerCompleteDoubleClickTimer);
              singleClick = true;
              }
              return myReturn;
              }
              private function onTimerCompleteDoubleClickTimer(evt:TimerEvent):void
              {
              singleClick = false; // set it to false after the timer interval
              }