requestEditModeFor method
Implementation
bool requestEditModeFor(
T item, int row, int col, MhItemsViewMoveFocusDirections direction) {
//Move to next cell
T item = filteredItemsSource[row];
do {
switch (direction) {
case MhItemsViewMoveFocusDirections.up:
row = row - 1;
break;
case MhItemsViewMoveFocusDirections.down:
row = row + 1;
break;
case MhItemsViewMoveFocusDirections.left:
col = col - 1;
if (col < 0) {
row = row - 1;
col = columnDefs.length - 1;
}
break;
case MhItemsViewMoveFocusDirections.right:
col = col + 1;
if (col >= columnDefs.length) {
row = row + 1;
col = 0;
}
break;
}
if (row >= filteredItemsSource.length || row <= 0) {
return false;
}
item = filteredItemsSource[row];
} while (!columnDefs[col].canEdit(item));
editModeIsRequestedForRow = row;
editModeIsRequestedForCol = col;
//Check to keep the limits
if (editModeIsRequestedForRow! < 0) {
editModeIsRequestedForRow = 0;
}
if (editModeIsRequestedForRow! >= filteredItemsSource.length) {
editModeIsRequestedForRow = filteredItemsSource.length - 1;
}
addSelectedItem(item: item, fromSelectBox: false, fromEditBox: true);
// We ensure that the Row is painted in the refresh function (Flutter TextField ensures that it is visible by default - so we just have to care, that the row is painted)
if (editModeIsRequestedForRow != null) {
widget.jumpTo(
item: item, blink: false, centerItem: false, onlyIfNotVisible: true);
}
// Refresh the view
setState();
return true;
}