1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
// Dans mon datagrid :
dg.addEventListener(KeyboardEvent.KEY_DOWN,listenKeyDg);
dg.addEventListener(DataGridEvent.ITEM_FOCUS_OUT,majQte);
// ma fonction :
private function listenKeyDg(evt:KeyboardEvent):void{
var row:Number;
var col:Number;
var dgEdit:DataGrid = DataGrid(evt.currentTarget);
switch(evt.keyCode)
{
case(Keyboard.DOWN):
row = dgEdit.editedItemPosition.rowIndex + 1;
col = dgEdit.editedItemPosition.columnIndex;
evt.currentTarget.editedItemPosition = { rowIndex:row ,columnIndex:col };
break;
case(Keyboard.UP):
row = dgEdit.editedItemPosition.rowIndex - 1;
col = dgEdit.editedItemPosition.columnIndex;
evt.currentTarget.editedItemPosition = { rowIndex:row ,columnIndex:col };
break;
case(Keyboard.LEFT):
row = dgEdit.editedItemPosition.rowIndex ;
col = dgEdit.editedItemPosition.columnIndex - 1;
evt.currentTarget.editedItemPosition = { rowIndex:row ,columnIndex:col };
break;
case(Keyboard.RIGHT):
row = dgEdit.editedItemPosition.rowIndex;
col = dgEdit.editedItemPosition.columnIndex + 1;
evt.currentTarget.editedItemPosition = { rowIndex:row ,columnIndex:col };
break;
case(13):
row = 1;
col = 2;
evt.currentTarget.editedItemPosition = { rowIndex:row ,columnIndex:col };
break;
}
} |
Partager