1 Reply Latest reply on Dec 17, 2007 1:10 PM by buabco

    comboBox with checkbox

    torloneg
      hi

      i try to build a combobox where every item is a checkbox using itemrender but i have a problem when the user click on a checkbox. When the user click the combo close the dropdown list.

      how can resolve this problem ???
      Thx

      <mx:ComboBox dataProvider="{ds..item}" labelField="@label" itemRenderer="com.itemRendererCB" x="10" y="10" width="151"/>

      -------------------------------------------------------------
      in "com" directory put this file
      -------------------------------------------------------------

      <?xml version="1.0" encoding="utf-8"?>
      <mx:HBox xmlns:mx=" http://www.adobe.com/2006/mxml" width="100%" height="100%">

      <mx:Script>
      <![CDATA[

      import mx.controls.Alert;


      private function onData(event:Event):void
      {
      this.addEventListener(MouseEvent.MOUSE_DOWN, disablePropagation);

      ck.selected = false;

      if ( data.@selected == "true"){
      ck.selected = true;
      }
      }

      private function onChange(event:Event):void
      {
      event.stopImmediatePropagation();
      }

      private function disablePropagation(event:Event):void
      {
      event.stopPropagation();
      }


      ]]>
      </mx:Script>


      <mx:CheckBox id="ck" label="{data.@label}" creationComplete="onData(event)" change="onChange(event);"/>
      </mx:HBox>