Hi,
I have the following code to activate the VirtualKeyBoard on the ONClickCell event in Android OS. When I type a new value with the VirtualKeyBoard, it does not overwrite the previous value, but, as you can see in the video, it inserts the new value before the old value.
My second problem, as you can see in the video, is that the CheckBox position of the "X" column has a wrong alignment, I think that its natural position should be centered, in Windows instead it is aligned to the right.
My code
procedure TFormOrdini.TMSFNCDataGridCarrelloVariantiEnter(Sender: TObject);
begin
//ON ENTER DATAGRID EVENT
EurFocusObject:= TFmxObject(TMSFNCDataGridCarrelloVarianti);
end;
procedure TFormOrdini.TMSFNCDataGridCarrelloVariantiExit(Sender: TObject);
begin
//ON EXIT DATAGRID EVENT
FServiceVTKeyboard.HideVirtualKeyboard;
end;
procedure TFormOrdini.TMSFNCDataGridCarrelloVariantiCellClick(Sender: TObject;
AColumn, ARow: Integer);
var
xCell: TTMSFNCDataGridCellCoord;
begin
//ONCELLCLIK DATAGRID EVENT
if not TMSFNCDataGridCarrelloVarianti.Columns[AColumn].ReadOnly and
(TMSFNCDataGridDatabaseAdapterVAR.Columns[AColumn].Field.DataType <> ftBoolean) then
begin
xCell.Column:= AColumn;
xCell.Row:= ARow;
TMSFNCDataGridCarrelloVarianti.EditCell(xCell);
end;
end;
procedure TFormOrdini.TMSFNCDataGridCarrelloVariantiGetInplaceEditorProperties(
Sender: TObject; ACell: TTMSFNCDataGridCellCoord; AInplaceEditor: TControl;
AInplaceEditorType: TTMSFNCDataGridInplaceEditorType);
begin
//ON GETINPLACEEDITOR DATAGRID EVENT
EurFocusObject:= TFmxObject(TMSFNCDataGridCarrelloVarianti);
EurFocusedInplaceEdit:= AInplaceEditor;
if not TMSFNCDataGridCarrelloVarianti.Columns[ACell.Column].ReadOnly then
EurShowVirtualKeyboard(EurFocusedInplaceEdit);
end;
procedure TFormOrdini.TMSFNCDataGridCarrelloVariantiAfterCloseInplaceEditor(
Sender: TObject; ACell: TTMSFNCDataGridCellCoord; ACancel: Boolean;
AValue: TValue);
begin
//ON AFTER CLOSE INPLACEEDITOR DATAGRID EVENT
FServiceVTKeyboard.HideVirtualKeyboard;
end;
procedure TFormOrdini.EurShowVirtualKeyboard(xFocusedObject: TFmxObject);
var
xCustomEdit: TCustomEdit;
xFieldType: TFieldType;
begin
{$IFDEF ANDROID}
if (FServiceVTKeyboard <> nil) and ((EurFocusObject <> nil) or (xFocusedObject <> nil)) then
begin
if EurFocusObject = TMSFNCDataGridCarrelloVarianti then
begin
if EurFocusedInplaceEdit <> nil then
begin
xFieldType:= TMSFNCDataGridDatabaseAdapterVAR.Columns[TMSFNCDataGridCarrelloVarianti.FocusedCell.Column].Field.DataType;
if not TMSFNCDataGridCarrelloVarianti.Columns[TMSFNCDataGridCarrelloVarianti.FocusedCell.Column].ReadOnly and (xFieldType <> ftBoolean) then
begin
xCustomEdit:= TCustomEdit(EurFocusedInplaceEdit);
case xFieldType of
ftInteger,ftSmallint: xCustomEdit.KeyboardType:= TVirtualKeyboardType.NumberPad;
ftFloat, ftCurrency, ftBCD: xCustomEdit.KeyboardType:= TVirtualKeyboardType.DecimalNumberPad;
end;
FServiceVTKeyboard.ShowVirtualKeyboard(EurFocusedInplaceEdit);
end;
end;
end
Thanks for your help
DATAGRID_ERROR.zip (3.3 MB)