--- In flexcoders@yahoogroups.com, "Mike_Robinson_98"
<[EMAIL PROTECTED]> wrote:
>
> --- In flexcoders@yahoogroups.com, "Manish Jethani"
> <manish.jethani@> wrote:
> >
> > On 5/8/07, Mike_Robinson_98 <mike_robinson_98@> wrote:
> > > Has anyone come up with a good way to let a user move up/down in an
> > > editable column of a datagrid using the keyboard? These columns
use a
> > > TextInput as the itemEditor.
> > >
> > > Right now I use a handler for the keyFocusChangeEvent on the
datagrid
> > > to handle TAB and Shift-TAB keys to move horizontally through the
> > > rows. However, moving up/down in the columns is more difficult
because
> > > the editor's TextInput captures the Return key and the
> > > TextFieldAutomationHelper class captures all the other interesting
> > > keystrokes (navigation keys like UP and DOWN arrows) and it
seems the
> > > DataGrid is only interested in the TAB key when it handles
focusChange
> > > events.
> > 
> > This simple test worked for me:
> > 
> > <?xml version="1.0"?>
> > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
> >     xmlns="*">
> >     <mx:DataGrid id="dg" editable="true" keyDown="handleKeyDown()">
> >             <mx:dataProvider>
> >                     <mx:Object name="foo" value="1" />
> >                     <mx:Object name="bar" value="2" />
> >             </mx:dataProvider>
> >     </mx:DataGrid>
> >     <mx:Script>
> >             private function handleKeyDown():void
> >             {
> >                     var v:Object = dg.editedItemPosition;
> >                     v.rowIndex++;
> >                     dg.editedItemPosition = v;
> >             }
> >     </mx:Script>
> > </mx:Application>
> > 
> > Use the down arrow key to move from foo to bar.
> >
> Thanks a lot for the reply. That is a nice, simple solution. 
> 
> I have one more slight problem along this line maybe you could shed
> some light on. In my app, I use the endEdit function for the datagrid.
> Unfortunately, although I move the focus to the column in the new row,
> the endEdit code gets call after this focus occurs and consequently
> focus is lost. I have tried 'callLater' for the focus method but have
> the same result. Even, setup a timer to delay the focus for 200 ms.
> Still endedit come along and focus is lost. Have you or any other
> reader run into this issue?
>
Another note - actually, the setting of the focus is what is causing
the endedit event for the previous cell. Seems like a catch-22.
Setting the focus caused the endevent for the previous cell which then
causes the current cell to lose focus. Again, I am probably making
things too complex.

Reply via email to