2 Replies Latest reply on Jan 24, 2012 5:21 AM by Mayur_2

    Can't focus on custom itemRenderer?

    jpwrunyan Level 1
      I have made a custom itemRenderer doubling as an itemEditor following the guidelines in the documentation.
      However, even though I have set the rendererIsEditor="true", when tabbing amongst other editable fields, the controls inside the itemRenderer do not receive focus. I can't help but think this is an oversight/bug but is there any way to jury-rig the itemRenderer to focus properly? At the moment my component is simply a CheckBox inside an HBox.

      Anyway, here is my code so you can see for yourself (I have included a CheckBox as itemRenderer so you can see the *desired* effect.

      <?xml version="1.0" encoding="utf-8"?>
      xmlns:mx=" http://www.adobe.com/2006/mxml" layout="vertical">
      import mx.controls.dataGridClasses.DataGridListData;
      import mx.controls.Alert;
      public var dp:Array = [{num:2, bool:true}, {num:3, bool:false}];
      <mx:DataGrid id="test" editable="true" dataProvider="{dp}">

      <mx:DataGridColumn dataField="num" headerText="num" />
      <mx:DataGridColumn dataField="bool"
      rendererIsEditor="true" editorDataField="selected" />

      <mx:DataGridColumn dataField="num" headerText="num" editable="true" />
      <mx:DataGridColumn dataField="bool" headerText="Sent" rendererIsEditor="true" editorDataField="blorch">
      <mx:HBox horizontalAlign="center">
      <mx:Boolean id="blorch" />
      <mx:CheckBox id="check" selected="{data.bool}" change="blorch=check.selected" />
      <mx:DataGridColumn dataField="num" headerText="num" editable="true" />
        • 1. Re: Can't focus on custom itemRenderer?
          jpwrunyan Level 1
          nevermind... I found the answer a few pages later in the docs...
          you have to implement the IFocusManagerComponent interface and then override drawFocus as below to set the focus on the checkBox... hope it works for multiple controls...

          <mx:HBox horizontalAlign="center" backgroundColor="#9933EE" implements="mx.managers.IFocusManagerComponent">
          override public function drawFocus(focused:Boolean):void {
          <mx:Boolean id="blorch" />
          <mx:CheckBox id="check" selected="{data.bool}" change="blorch=check.selected" updateComplete="blorch=check.selected" />
          • 2. Re: Can't focus on custom itemRenderer?

            Good answer it works for Forward Tab.

            But when we user revers Tab order ( shift + Tab on win) it gives an error.