TMSFNCDataGrid - Android VirtualKeyBoard and CheckBox Display

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)

Hi,

It's unclear why you are calling the virtual keyboard yourself. by default when editing, the virtual keyboard should be shown automatically. Editing the cell with the default inplace editing does not exhibit this issue. Can you put together a ready-to-run sample so we can investigate here?

About the checkbox, please use

procedure TForm1.TMSFNCDataGrid1GetCellProperties(Sender: TObject;
  ACell: TTMSFNCDataGridCell);
begin
  ACell.ControlAlign := gcaClient;
end;

Hi,

it works lso I get a correct align, however display of checkbox controls is different between MSWindows and Android, so I compiled differently, in this way I can get controls centered in both OS.

{$IFDEF MSWINDOWS}
ACell.ControlAlign := gcaNone;
ACell.ControlPosition:= gcpCenterCenter;
{$ENDIF}

{$IFDEF ANDROID}
ACell.ControlAlign := gcaClient;
{$ENDIF}

I would also like to ask you how I can align the text of the float and currency fields to the right, because even though the field has Alignment = taRightJustify the grid always aligns to the left.

for the VirtualKeyboard problem, I will debug to find out more, unfortunately in my application I cannot use the VirtualKeyboard automatically but I am forced to use it manually, I will try to prepare a test to send it to you, so that you can investigate

Thanks for your help

Thanks for the feedback. For the alignment, the best option is to use OnGetCellLayout event

procedure TForm1.TMSFNCDataGrid1GetCellLayout(Sender: TObject;
  ACell: TTMSFNCDataGridCell);
begin
  ACell.Layout.TextAlign := gtaTrailing;
end;