Maybe fake TAB/SHIFT-TAB/ENTER/SHIFT_ENTER events when you get arrow key 
events.  For TAB/SHIFT-TAB you'll need to dispatch KEY_FOCUS_CHANGE

Alex Harui
Flex SDK Developer
Adobe Systems Inc.<http://www.adobe.com/>
Blog: http://blogs.adobe.com/aharui

From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf 
Of philcruz
Sent: Monday, June 15, 2009 11:47 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] using arrow keys to move around editable datagrid





I'm having a problem implementing keyboard navigation with a custom editable 
datagrid. I want to have it such that if you are editing a cell, you can use 
the arrow keys to move around and edit other cells. Given a simple grid I can 
capture the keydown and set the editedItemPosition. However, the custom grid 
has a listener for ITEM_EDIT_END and the handler for that event is

private function handleEditEnd(event:DataGridEvent):void
{
trace("datagrid.handelEditEnd");
trace(event.reason.toString());

if (event.reason == mx.events.DataGridEventReason.CANCELLED)
{
// Do not update cell.
return;
}
// get the new data from the editor
var newData:String = 
mx.controls.TextInput(event.currentTarget.itemEditorInstance).text;
var row:int = event.rowIndex;
var col:int = event.columnIndex - 1;
trace("newData: " + newData);
event.preventDefault();
this.destroyItemEditor();
//try to update the data in the data provider
this.dataProvider[row].cells[col].data = newData;
this.dataProvider.itemUpdated(event.itemRenderer.data);

}

I got this by looking at the example in the livedocs for "Passing multiple 
values back from an item editor" 
[http://livedocs.adobe.com/flex/3/html/celleditor_8.html#247667] which shows 
using event.preventDefault() and destroyItemEditor(). However, this causes 
problems with getting the keyboard navigation to work. If I comment out those 
lines, the keyboard navigation works but then the datagrid doesn't update the 
dataProvider.

Any ideas how to work around this?

-Phil

Reply via email to