TeeGrid OnTap

How can I work with the const Point: TPointF to determine the row that was tapped?

I am trying to change the selected row when the user taps the grid.

TIA

Really would like a reply to this. It has me stumped.

Hello,

Apologies for the delay with the reply. The detail for the information required is found via:

var myColumn : TColumn;
      myRow : Integer;
      myX; myY: Integer;
begin
  //myX := x
  //myY := y
  myColumn := TeeGrid1.Columns.FindAt(myX,TeeGrid1.Width);
  myRow := TeeGrid1.Rows.RowAt(myY,TeeGrid1.Height);

  ShowMessage ('Col: ' + IntToStr(myColumn.ID) + ' Row: ' +  IntToStr(myRow));
end;

That could source from the x,y of a mousedown/up or the Point of a Tap but we’re delayed on getting to the test for the tap.

Regards,
Marc

Thanks mcuh! I’ll try it out tonight.

This worked very well:

procedure TFudleyMain.TeeGrid1Tap(Sender: TObject; const Point: TPointF);
var
      myRow : Integer;
      myX, myY: single;
      hgt : single;
begin
  myX := point.X;
  myY := point.Y;
  hgt :=  TeeGrid1.Height;

  myRow := TeeGrid1.Rows.RowAt(myY,hgt);
  TeeGrid1.Selected.Row :=myRow;
end;

Great, thanks for the feedback.

Unfortunately TeeGrid1.Rows.RowAt only works to row 7. Past that it returns -1, even though there are several rows past that.

I should clarify what I am trying to do.

This is for mobile only. I would like the user to be able to tap on the row they want to move to, and the selected row/record becomes the one tapped on.

Any help you can offer is appreciated.

So is this a bug?

Hello,

I’ve tried it in the CellEditors project (FMX on Windows) with the following co-ordinates;

procedure TFormCellEditors.Button1Click(Sender: TObject);
var myColumn : TColumn;
    myRow : Integer;
begin
  myColumn := TeeGrid1.Columns.FindAt(160,TeeGrid1.Width);
  myRow := TeeGrid1.Rows.RowAt(218,TeeGrid1.Height);

and it returns correctly, column 2, row 9.

It may be a problem limited to Tap. What mobile devices have you tried?

With thanks.
Regards,
Marc Meumann

Hi Marc,

I’m using a Galaxy S10E.

-garry

Amy ideas on this?

I’ve attached a small screen shot.

You can see the selected row, and also a light blue rectangle around the cell I just tapped on. So teegrid knows I tapped there since it painted the light blue rectangle, but its just not moving the selection.

Hope this provides a clue to what’s happening. I really need this to work, as users on android will expect a tap to change the selection .

Thanks much!

Hello Garry,

Apologies that you’re not getting a quick answer for this. Resource time is being assigned to the issue and hopefully we can get some feedback to you very soon.

Regards,
Marc

Hello Garry,

This is still checking out ok on tests on a mobile device. In this case a Realme 6 on Android 11.

I can make the test project available if you think it may be useful. It runs 10,000 lines and marks the selected row as an arrow at row beginning. I put a label in to confirm the selected row.

It reports badly only for the last row on a visible screen where the row is not complete. In this case it returns a -1.

Using RAD Studio 12 with TeeGrid v1.14.

Apologies once again for taking so long to get here.

Regards,
Marc

This is still an issue with the latest version…

Hello ,

This is being re-checked. We’ll put up a demo shortly that we can use as a common test-bed.

Regards,
Marc Meumann

Thanks much !

Hello,

We’ll follow up with the example project to highlight this, but my tests run here are giving better positioning results using the Mousedown event in the Android project than Tap.

Example:

procedure THeaderFooterForm.TeeGrid1MouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Single);
var
  myRow : Integer;
  myX, myY: single;
  hgt : single;
begin
  myX := X;
  myY := Y;
  hgt :=  TeeGrid1.Height;

  myRow := TeeGrid1.Rows.RowAt(myY,hgt);
  TeeGrid1.Selected.Row :=myRow;

  Label1.Text := IntToStr(TeeGrid1.Selected.Row);
end;

Tap is working but empirical tests (so far) show the need to add a small vertical offset of 15 pixels for the vertical cells’ demarcation line. Using RAD Studio 12.1, TeeGrid v1.18.

Regards,
Marc